PHP-ios,php推送报错
php已经加载openssl模块,防火墙关闭,报错如下:
Warning: stream_socket_client() [function.stream-socket-client]: Unable to set local cert chain file `ck.pem'; Check that your cafile/capath settings include details of your certificate and its issuer in /web1/app/testdeom.php on line 31
Warning: stream_socket_client() [function.stream-socket-client]: failed to create an SSL handle in /web1/app/testdeom.php on line 31
Warning: stream_socket_client() [function.stream-socket-client]: Failed to enable crypto in /web1/app/testdeom.php on line 31
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /web1/app/testdeom.php on line 31
Failed to connect: 0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果php已经加载openssl模块,并且排除防火墙的原因。
原因:推送证书的问题。
1.确认你的推送证书没问题吗?
生成pem步骤:
1.下载下来你配置好的推送证书aps_developer_identity.cer 文件。
2.转换 .cer 文件到 .pem 文件:
openssl x509 -in aps_developer_identity.cer -inform der
-out PushChatCert.pem
3.在把你“钥匙”推送证书导出成的.p12到.pem文件:
openssl pkcs12 -nocerts -out PushChatKey.pem -in PushChatKey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
4.合并两个pem文件:cat PushChatCert.pem PushChatKey.pem > ck.pem
5.测试证书是否可用:
openssl s_client -connect gateway.sandbox.push.apple.com:2195
-cert PushChatCert.pem -key PushChatKey.pem
参考:Apple Push Notification Services Tutorial: Part 1/2
class pushNotifications {
...
private $sslPem = 'cert.pem';
...
function connectToAPNS(){
$streamContext = stream_context_create();
stream_context_set_option($streamContext, 'ssl', 'local_cert', dirname(__FILE__) . '/' . $this->sslPem);
参照:http://stackoverflow.com/a/809697/841070