3

php で Apples Push Notification Service (apns) に接続しようとしています。コマンドを使用すると

openssl s_client -connect gateway.push.apple.com:2195 -cert AppCert.pem -key AppKeyNoPass.pem -CAfile ca.pem

コンソールで、最後の行に「Verify return code: 0 (ok)」という長いメッセージが表示されます。次の PHP コードを使用すると、いくつかの警告が表示されます。

$uuid = '11111111-22222222-33333333-44444444-55555555-66666666-77777777-88888888';
$url = 'ssl://gateway.push.apple.com:2195';

$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', 'App.pem');
stream_context_set_option($streamContext, 'ssl', 'cafile', 'ca.pem');

$socketClient = stream_socket_client($url, $error, $errorString, 60, STREAM_CLIENT_CONNECT, $streamContext);

stream_socket_client() の PHP 警告は次のとおりです。

Warning: stream_socket_client() [function.stream-socket-client]: SSL operation failed with code 1. OpenSSL Error messages: error:14094416:SSL routines:SSL3_READ_BYTES:sslv3 alert certificate unknown
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error)

何か考えはありますか?証明書のフォーマットに問題がありますか?

ありがとう

4

1 に答える 1

2

私はこのチュートリアルを使用しましたが、すべてうまくいきました。キー ファイルに関するすべての詳細と、ダウンロード用のphp プッシュ サンプル ファイルもあります。それが役立つことを願っています。

于 2013-01-17T13:15:07.170 に答える