title: How can I use the Apple Push Notification Service (apns) with php?
body: <p>I'm trying to connect to Apples Push Notification Service (apns) with php. If I use the  command </p>
  
  <pre><code>openssl s_client -connect gateway.push.apple.com:2195 -cert AppCert.pem -key AppKeyNoPass.pem -CAfile ca.pem
  </code></pre>
  
  <p>on the console I get a long message with "Verify return code: 0 (ok)" in the last line. If I use the following PHP code I get some warnings. </p>
  
  <pre><code>$uuid = '11111111-22222222-33333333-44444444-55555555-66666666-77777777-88888888';
  $url = 'ssl://gateway.push.apple.com:2195';
  
  $streamContext = stream_context_create();
  stream_context_set_option($streamContext, 'ssl', 'local_cert', 'App.pem');
  stream_context_set_option($streamContext, 'ssl', 'cafile', 'ca.pem');
  
  $socketClient = stream_socket_client($url, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);
  </code></pre>
  
  <p>Here are the PHP Warnings for stream_socket_client()</p>
  
  <pre><code>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
  Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto
  Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error)
  </code></pre>
  
  <p>Do you have any idea? Do I have some problems with the certificate formats?</p>
  
  <p>Thanks</p>