本文介绍了警告:stream_socket_client():无法设置私钥文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在终端中运行PHP时无法得到这些错误,因为php simplepush.php

unable to get this getting these errors when running PHP in terminal as php simplepush.php

Warning: stream_socket_client(): Unable to set private key file `/users/accenture/Desktop/newAPNS/ck.pem' in /users/accenture/Desktop/newAPNS/simplepush.php on line 22

Warning: stream_socket_client(): failed to create an SSL handle in /users/accenture/Desktop/newAPNS/simplepush.php on line 22

Warning: stream_socket_client(): Failed to enable crypto in /users/accenture/Desktop/newAPNS/simplepush.php on line 22

Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error) in /users/accenture/Desktop/newAPNS/simplepush.php on line 22

Failed to connect: 0

我使用raywenderlich文章创建了所有证书和pem文件,

I created all certificates and pem file by using raywenderlich article, http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1#comments

推荐答案

问题是pem文件不正确,我使用。
创建p12文件和使用p12创建pem文件对我不起作用。正确创建p12并使用p12创建pem文件的过程如下所示

Problem is pem file wasn't correct, I created pem file using http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 .Creation of p12 file and with p12 creating pem file are not working for me. Correct process to create p12 and with p12 creating pem file as bellow

从Apple获得应用程序的证书后,将您的密钥和Apple证书导出为p12文件。以下是有关如何执行此操作的快速演练:

Once you have the certificate from Apple for your application, export your key and the apple certificate as p12 files. Here is a quick walkthrough on how to do this:


  1. 单击Keychain Access中证书旁边的显示箭头,然后选择证书和键盘。

  2. 右键单击并选择导出2项....

  3. 从下拉列表中选择p12格式并将其命名为cert.p12。

现在将p12文件转换为pem文件:

Now convert the p12 file to a pem file:

$ openssl pkcs12 - 在cert.p12 -out中apple_push_notification_production.pem -nodes -clcerts

$ openssl pkcs12 -in cert.p12 -out apple_push_notification_production.pem -nodes -clcerts

这对我有用,现在我收到推送通知。

This is working for me, now I am getting a push notification.

这篇关于警告:stream_socket_client():无法设置私钥文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-12 09:34