Error sending iOS push notifications using PHP -
i'm getting following error when trying send 'push notifications' connecting apns using php:
warning: stream_socket_client(): ssl operation failed code 1. openssl error messages: error:14090086:ssl routines:ssl3_get_server_certificate:certificate verify failed warning: stream_socket_client(): failed enable crypto warning: stream_socket_client(): unable connect ssl://gateway.push.apple.com:2195 (unknown error)
here code:
$payload = '{"aps":{"alert":"' . $message . '","sound":"default"}}'; $ctx = stream_context_create(); stream_context_set_option($ctx, 'ssl', 'local_cert', 'certificate.pem'); stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer'); $fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err, $errstr, 60, stream_client_connect | stream_client_persistent, $ctx); $msg = chr(0) . pack('n', 32) . pack('h*', $item) . pack('n', strlen($payload)) . $payload; $result = fwrite($fp, $msg, strlen($msg)); fclose($fp);
root certificate , adding following line fixed issue
`stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');`
Comments
Post a Comment