Handshake failure in ios push notification
I want to send push notification to Ios device and here is my code,
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert',
ABSPATH.'apns-dev.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $password);
$fp = stream_socket_client('ssl://gateway.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;
$payload = $message;
foreach ($token as $deviceToken)
{
$msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload;
}
$result = fwrite($fp, $msg, strlen($msg));
if (!$result)
echo 'Message not delivered' . PHP_EOL;
else
echo 'Message successfully delivered' . PHP_EOL;
fclose($fp);
But I got errors like:
- stream_socket_client (): SSL operation failed with code 1. OpenSSL error messages:
Error: 14094410: SSL routines: ssl3_read_bytes: sslv3 failed handshake.- stream_socket_client (): unable to connect to ssl: //gateway.push.apple.com: 2195 (Unknown error)
- stream_socket_client (): Failed to enable cryptography
How to solve this problem?
+3
source to share
No one has answered this question yet
Check out similar questions: