Apple Push Notification Service: Certificate Install Server Side?

柔情痞子 提交于 2019-12-09 11:10:52

问题


I've followed the instructions at How to build an Apple Push Notification provider server (tutorial) in an attempt to set up a push notification server.

When I attempt to connect with the following PHP code

// connect to apns server
$strAPNSUrl = 'ssl://gateway.sandbox.push.apple.com:2195';
$strAPNSCert = 'dev.pem';

// generate stream
$oStreamContext = stream_context_create();
stream_context_set_option($oStreamContext, 'ssl', 'local_cert', $strAPNSCert);

// create the socket connection
$oAPNS = stream_socket_client($strAPNSUrl, $iError, $strError, 2, STREAM_CLIENT_CONNECT, $oStreamContext);

I get the following warning

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert

Based on what information I've been able to find on Google, the issue seems to be my certificate.

I'm generating my csr and pem files in OS X (pem files per the instructions in the tutorial). Once I have created dev.pem I am uploading it to my hosting provider and attempting to run my php script. Is this the correct way to create and "install" the certificate?

I've run out of debugging ideas. Any direction would be great.


回答1:


Path to dev.pem was incorrect on my server.

The instructions are indeed the correct way to generate the .pem file. Once created it can be used on any machine (not just the machine that generated it).




回答2:


Were you able to use the same .pem file in your server? And as you said...on any machine.

I have follow this tutorial and I could send messages from my machine (the one were the certificate was generated) but I have tried copy all files and run the script in another machine and I have got the same errors that you have got.

How have you done to make it works in another machine? Have you installed the .pem file? Any special config?

Cheers



来源:https://stackoverflow.com/questions/1635111/apple-push-notification-service-certificate-install-server-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!