Reputation: 884
i'm trying to implement push notification in my application, for this i tried to use easyApns, i follow the steps, and implement the classes on my linux based. but unfortunately i stil betting some errors related to certificates.
my error is:
Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown in /var/www/html/apns/classes/class_APNS.php on line 401
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /var/www/html/apns/classes/class_APNS.php on line 401
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /var/www/html/apns/classes/class_APNS.php on line 401
Notice: Failed to connect to APNS: 0 . 1) APNS::__construct -> File: apns.php (line 50) 2) APNS::_fetchMessages -> File: class_APNS.php (line 217) 3) APNS::_pushMessage -> File: class_APNS.php (line 376) 4) APNS::_triggerError -> File: class_APNS.php (line 405) in /var/www/html/apns/classes/class_APNS.php on line 509
i gusse it's an error related to the certificate (the .pem file)
my .pem file wa generated using the following command
openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts
and it was placed on the server (linux based) and given chmod 644 privileges
should i do any thing else.....
Upvotes: 1
Views: 6374
Reputation: 1734
Double check that before to generate the .pem, you export correctly the "2" items from Keychain:
Apple Development IOS Push Services + user name key.
Then export the2 items
Upvotes: 0
Reputation: 6155
Are you able to connect to apns using your certificate? try following command to check that:
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile server-ca-cert.pem
If the command terminates, you are not able to connect. If it continues running and lets you type into the socket, you have connected successfully.
Upvotes: 6
Reputation: 726
I have found out that for the command to work it is necessary to :
reference: https://developer.apple.com/library/ios/#technotes/tn2265/_index.html
Upvotes: 1
Reputation: 726
I have the same issue. Downloaded the .p12 file then $ openssl pkcs12 -in apns-dev-cert.p12 -out apns-dev-cert.pem -nodes -clcerts then using Nilesh command: $ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert YourSSLCertAndPrivateKey.pem -debug -showcerts -CAfile server-ca-cert.pem then i get this error
unable to load client certificate private key file 140405386606400:error:0906D06C:PEM routines:PEM_read_bio:no start line:pem_lib.c:696:Expecting: ANY PRIVATE KEY
thanks
Upvotes: 0