title: How to create P12 file using openssl
body: <p>I am having some serious problems with regards to being able to create a p12 file to place on my windows server. </p>
  
  <p>I have used two different websites to be able to help me work out what i need to do: </p>
  
  <p><a href="http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1" rel="nofollow">http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1</a></p>
  
  <p>The second website i used was a comment from within the website was the following: </p>
  
  <p><a href="http://arashnorouzi.wordpress.com/2011/06/19/sending-apple-push-notifications-in-asp-net-and-c-%E2%80%93-part-4-apns-sharp-c-wrapper-class/" rel="nofollow">http://arashnorouzi.wordpress.com/2011/06/19/sending-apple-push-notifications-in-asp-net-and-c-–-part-4-apns-sharp-c-wrapper-class/</a></p>
  
  <p>First of all i create a Certificate signing request. 
  I then upload this to my app ID which alows me to generate a ape_dev certificate. 
  I then go to my key chain and navigate to the "keys" i export the .p12 certificate that i just created. </p>
  
  <p>I now have three different files</p>
  
  <p><strong>My p12 file, my development certificate and my certificate signing request.</strong> </p>
  
  <p>I then open terminal and i type the following:</p>
  
  <pre><code>$ openssl x509 -in aps_development.cer -inform der -out PushChatCert.pem
  </code></pre>
  
  <p>This then creates a new pem certificate. </p>
  
  <p>The thing i type is the following </p>
  
  <pre><code>$ openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12
  </code></pre>
  
  <p>It prompts for the password which i enter, i use the same password as the one when i created the certificates. </p>
  
  <p>After i have done this I'm left with 2 new files both of which are PEM files. </p>
  
  <p>I need to combine both of these PEM files into one p12 file for it to be able to work on my windows server. </p>
  
  <p>I have tried combining it using the following line </p>
  
  <pre><code>openssl pkcs12 -export \
  -in aps_developer_identity.pem \
  -out aps_developer_identity.p12  \
  -inkey APSCertificates.pem
  </code></pre>
  
  <p>This in fact works and gives me a p12 file. 
  I then switched back to he raywenderlich website and i typed the following: </p>
  
  <pre><code>$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 
  -cert PushChatCert.pem -key PushChatKey.pem
  </code></pre>
  
  <p>It loads but i recieve the following error: </p>
  
  <pre><code>error:num=20:unable to get local issuer certificate
  </code></pre>
  
  <p>Please does any one know what im doing wrong im so fed up of going round in circles. </p>
  
  <p>When i upload the certificate to the server and put the ad-hoc version off the application on the device im still not receiving any notifications that i am sending </p>
  
  <p>Thanks in advance. </p>