我将尝试使用php连接到苹果推送通知服务(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)
您是否有任何想法?我的证书格式是否存在问题?
谢谢