title: APNS + PHP "stream_socket_client(): Failed to enable crypto"
body: <p>I'm having trouble with using APNS with PHP and getting the following message:</p>
  
  <pre><code>stream_socket_client(): Failed to enable crypto
  </code></pre>
  
  <p>The problem only happens sometimes, and other times it would actually send the push.</p>
  
  <p>Since I have the test script on a loop of 10 iterations, I would sometimes get this:</p>
  
  <pre><code>stream_socket_client(): SSL: Connection reset by peer
  </code></pre>
  
  <p>I'm testing using the sandbox server <code>tls://gateway.sandbox.push.apple.com:2195</code></p>
  
  <p>Here is what I tried:</p>
  
  <ul>
  <li>I tried to reissue the PEM and all certificates with it.</li>
  <li>I played around with the request protocol <code>sslv3://</code> and <code>tls://</code>.</li>
  <li>I played around with the passphrase (push worked without the passphrase btw)</li>
  <li>I tried searching stackoverflow for a solution and nothing worked.</li>
  <li>Checked pem file permissions <code>644</code></li>
  <li>Checked pem parent directories permissions <code>755</code></li>
  </ul>
  
  <p>It seems that all the solutions I found on Google and SO are people having problem pushing altogether.</p>
  
  <p>I feel like the service is rate limited maybe? Because we waited a while (around 15 minutes) and then tried it again, and was able to successfully push around 100 messages until I started getting that message again.</p>