Once you create the provisional certificates and click on the notification for both development and distribution. Follow the steps to create a push notification.
To use the certificates you created, you need to create a PEM file that stores both the Apple Push Notification Service SSL certificate and your private key. You can create a PEM file from the terminal.
Change to the directory containing the certificates and key generated earlier, and follow these steps. The file names here reflect the names of the certificates that were generated as part of this lesson. You must update the syntax to match the names you gave your certificates.
First create a PEM file for the application certificate. You can do this by double-clicking the aps_developer_identity.cer certificate file, then open the Keychain Assistant and export the certificate to the ap12 file, and then convert it to a PEM file in the same way that PushNotificationApp.p12 is converted to a PEM file. Alternatively, you can use a single command line that converts the aps_developer_identity.cer certificate file directly into a PEM file. Here we select one command line option, as shown below:
openssl x509 -inform der -outform pem -in aps_developer_identity.cer -out PushNotificationAppCertificate.pem
Now create the application PEM key file as follows. You need to enter a password to import and a phrase to transfer PEM:
openssl pkcs12 -in PushNotificationApp.p12 -out PushNotificationAppKey.pem -nocerts
Enter the password to import: MAC is confirmed OK Enter the phrase: Verify - enter the phrase to send PEM:
Now merge the two files:
cat PushNotificationAppCertificate.pem PushNotificationAppKey.pem > PushNotificationAppCertificateKey.pem
Open a Mac terminal and run the following line from the directory containing the certificates you created:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushNotificationAppCertificate.pem -key PushNotificationAppKey.pem
Then you are prompted to enter the password for the passed key:
Enter pass phrase for PushNotificationAppKey.pem:
If everything worked, the server should send you a lot of information, which might look something like this:
CONNECTED(00000003) depth=1 /C=US/O=Entrust, Inc./OU=www.entrust.net/rpa is incorporated by reference/OU=(c) 2009 Entrust, Inc./CN=Entrust Certification Authority - L1C verify error:num=20:unable to get local issuer certificate verify return:0 ... Key-Arg : None Start Time: 1326899631 Timeout : 300 (sec) Verify return code: 0 (ok) At the end of this, you can enter some text and then select the return key. We entered the text "**Hello World**". **Hello World closed**
This completes the connection to the server and checks if our certificates are working.
