Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

terminal error in between connecting SSL certificate and private key to set up a secure connection:

i am trying to do push notification in my app and following this link http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12

my system has been successfully connected with telnet but when i enter the query for connecting ssl certificate and private key then found a error

$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key.pem
unable to load client certificate private key file
1301:error:0906D06C:PEM routines:PEM_read_bio:no start line:/SourceCache/OpenSSL098/OpenSSL098-44/src/crypto/pem/pem_lib.c:648:Expecting: ANY PRIVATE KEY

any one can tell me what type of error and what's the solution of it?

Thanks in advance

like image 557
Anju Avatar asked Apr 09 '12 07:04

Anju


People also ask

How do I link a private key to a SSL certificate?

Assign the existing private key to a new certificateSign in to the computer that issued the certificate request by using an account that has administrative permissions. Select Start, select Run, type mmc, and then select OK. On the File menu, select Add/Remove Snap-in. In the Add/Remove Snap-in dialog box, select Add.

How do I fix SSL error on Mac?

Go to  Apple menu > System Preferences > Date & Time > and make sure everything is correct. Check the Apple Status page for any issues with the App Store being offline. Wait a while (15 minutes or so), quit and relaunch the Mac App Store, and try the downloads/updates again.


2 Answers

The following command is good enough to verify the key/cert:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert push_development.pem

The key part is to select both certificate and private key when exporting the .p12 from Keychain Access (you will be asked for 3 passwords, one for the .p12, one for the cert, one for the private key).

To convert .p12 to .pem, follow the instruction from Apple:

openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes
like image 78
ohho Avatar answered Sep 19 '22 20:09

ohho


At first i was facing this problem too.

We have two files

1) one is aps_development.cer from apple 2) Another 1 is from the keychain access with the common name that we just created.

After that, both convert it to .pem files. For example, cert.pem and key.pem. After that combine this two files using below command

cat cert.pem key.pem > ck.pem

At first I openssl using below command.

openssl s_client -connect gateway.sandbox.push.apple.com:2195
    -cert cert.pem -key key.pem

Which returns me the error you mentioned. After that I try using

openssl s_client -connect gateway.sandbox.push.apple.com:2195
    -cert cert.pem -key ck.pem

Then its working already. Hope this helps.

like image 45
user774150 Avatar answered Sep 18 '22 20:09

user774150