如何将Apple推送通知服务(apns)与php结合使用?

如何将Apple推送通知服务(apns)与php结合使用?,php,ssl,apple-push-notifications,Php,Ssl,Apple Push Notifications,我正在尝试用php连接苹果推送通知服务(apns)。如果我使用命令 openssl s_client -connect gateway.push.apple.com:2195 -cert AppCert.pem -key AppKeyNoPass.pem -CAfile ca.pem 在控制台上,我收到一条长消息,最后一行是“验证返回代码:0(确定)”。如果我使用下面的PHP代码,我会得到一些警告 $uuid = '11111111-22222222-33333333-44444444-555

我正在尝试用php连接苹果推送通知服务(apns)。如果我使用命令

openssl s_client -connect gateway.push.apple.com:2195 -cert AppCert.pem -key AppKeyNoPass.pem -CAfile ca.pem
在控制台上,我收到一条长消息,最后一行是“验证返回代码:0(确定)”。如果我使用下面的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)