Hi I'm having trouble sending push notifications from a cron job invoked php script. However the same script works when I invoke the script from the terminal so I know its a problem retrieving the ck.pem. When I hit the script from the terminal I just use the lines
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
to get the ck.pem and it works because the ck.pem file is right on my desktop and local. When I hit the script thats invoked by the cron job it does not have the ck.pem file locally so I uploaded the ck.pem file to the server so the php script invoked from the cron job could access it and this is the code I use to retrieve it
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', file_get_contents("http://www.website.com/Certificates/ck.pem"));
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
however I get the errors
PHP Warning: stream_socket_client(): Failed to enable crypto
PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error)
PHP Warning: stream_socket_client(): SSL operation failed with code 1. OpenSSL Error messages:
and all these errors happen on the third line of code in the following segment:
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
if (!$fp)
exit("Failed to connect: $err $errstr" . PHP_EOL);
echo 'Connected to APNS' . PHP_EOL;
So like I said Im pretty sure its because of the ck.pem file and I made sure that ports 2195 and 2196 are open so it is not that and I can't figure this out. Any help or suggestions would be greatly greatly appreciated!