I have a PHP file with the following content that works fine on developing ceritficates, but when I switch to the production certificate for PHP errors and give the message below, but it does it in about 50% of cases. Another 50% it works. Does anyone know why this might happen?
<?php
$deviceToken = 'xxxxxx';
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', dirname(__FILE__)."/prod.pem");
$number = 5;
$fp = stream_socket_client('ssl://gateway.push.apple.com:2195', $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstr\n";
}
else {
print "Connection OK\n";
$msg = $_GET['msg'];
$payload['aps'] = array('alert' => $msg, 'badge' => 1, 'sound' => 'default');
$payload = json_encode($payload);
$msg = chr(0) . pack("n",32) . pack('H*', str_replace(' ', '', $deviceToken)) . pack("n",strlen($payload)) . $payload;
print "sending message :" . $payload . "\n";
fwrite($fp, $msg);
fclose($fp);
}
?>
PHP error:
Warning: stream_socket_client () [function.stream-socket-client]: it is not possible to install the local certificate chain file `/var/www/vhosts/thissite.com/httpdocs/prod.pem '; Make sure your cafile / capath settings contain information about your certificate and its issuer in /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php on line 19
: stream_socket_client() [function.stream-socket-client]: SSL /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 19
: stream_socket_client() [function.stream-socket-client]: /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 19
: stream_socket_client() [function.stream-socket-client]: ssl://gateway.sandbox.push.apple.com: 2195 ( ) /var/www/vhosts/thissite.com/httpdocs/pushMessageLive.php 19
0