Apple ガイドに従って、ネットブックに証明書を設定しました。次に、プッシュ通知を実行しようとすると、次のエラーが発生します。
Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094410:SSL routines:SSL3_READ_BYTES:sslv3 alert handshake failure in xxxx.php on line 92
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in xxxx.php on line 92
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in xxxx.php on line 92
Failed to connect 0
これは私のPHP関数です:
function push($deviceToken,$badge,$message) {
$sound = "default";
// Construct the notification payload
$body = array();
$body['aps'] = array("alert" => $message);
if ($badge)
$body['aps']['badge'] = $badge;
if ($sound)
$body['aps']['sound'] = $sound;
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'apns-dev.pem');
$fp = stream_socket_client("ssl://gateway.sandbox.push.apple.com:2195", $err, $errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect $err $errstrn";
return;
} else {
print "Connection OK\n";
}
$payload = json_encode($body);
$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);
}
Appleゲートウェイをテストしようとしましたが、これが私の出力です:
$ telnet gateway.sandbox.push.apple.com:2195
Trying 212.48.8.140...
telnet: connect to address 212.48.8.140: Operation timed out
telnet: Unable to connect to remote host
それを解決するためのアイデアはありますか?
編集:リモートサーバーに証明書を設定する必要があるかどうかわかりません
解決済み: 私のエラーは apns-dev.pem のパスです