Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apple Push Notification Service: Certificate Install Server Side?

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.

like image 739
Jason George Avatar asked Oct 28 '09 03:10

Jason George


People also ask

Can you have more than one Apple push certificate?

Actually you can create only 2 apple push certificates for one App ID and no more.

How do I renew Apple push service certificate?

Click Apple Push Certificates portal. In the new tab, sign in to the Apple portal with the Apple ID and password you used when you created the certificate. Next to the certificate you want to renew, click Renew and accept the terms of use.


1 Answers

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).

like image 71
Jason George Avatar answered Oct 27 '22 17:10

Jason George