服务器脚本中的 APN 错误
我在发送有效负载数据时在我的 php 脚本中收到此错误。
Warning: stream_socket_client() [function.stream-socket-client]:
Unable to set private key file `/Applications/XAMPP/xamppfiles/htdocs/test/apn/apns-dev.pem'
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
Warning: stream_socket_client() [function.stream-socket-client]:
failed to create an SSL handle
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
Warning: stream_socket_client() [function.stream-socket-client]:
Failed to enable crypto
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
Warning: stream_socket_client() [function.stream-socket-client]:
unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error)
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
原因是什么?我需要更改任何设置吗? 我还在服务器中安装了 .pem 文件。
谢谢
I am getting this error in my php script , while sending payload data.
Warning: stream_socket_client() [function.stream-socket-client]:
Unable to set private key file `/Applications/XAMPP/xamppfiles/htdocs/test/apn/apns-dev.pem'
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
Warning: stream_socket_client() [function.stream-socket-client]:
failed to create an SSL handle
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
Warning: stream_socket_client() [function.stream-socket-client]:
Failed to enable crypto
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
Warning: stream_socket_client() [function.stream-socket-client]:
unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Unknown error)
in /Applications/XAMPP/xamppfiles/htdocs/test/apn/push.php on line 42
What is the reason ? Do I need to change any settings?
I have also installed the .pem file in the server.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以发布用于连接 APN 的 PHP 代码 (push.php) 吗?
一些在黑暗中拍摄的照片:
- 证书和私钥都在该 .pem 文件中吗?
- 您是否从私钥文件中删除了密码,或者您是否在 PHP 代码中正确设置了密码?
- 运行脚本的用户是否具有访问/读取证书/密钥文件的适当 unix 权限?
- 您可以从您的机器访问Apple的服务器吗?您可以通过运行 telnet 进行测试。
Can you post the PHP code (push.php) you're using to connect to APN?
Some shots in the dark:
- Are both the certificate and private key in that one .pem file?
- Did you remove the password from the private key file, or are you setting it properly in your PHP code?
- Does the user running your script have the proper unix permissions to access/read the cert/key file?
- Can you access Apple's server from your machine? You can test by running telnet.
我遇到了这个问题,密钥生成过程是问题所在,证书和密钥文件有两个不同的 openssl 命令,而我对两者都使用相同的命令。以下是我生成证书并从私钥文件中删除密码的方法(假设您已导出 .p12 文件):
请注意前两个 openssl 命令的区别。
I had this problem and the key generation process was the issue, there are two different openssl commands for certificate and key file whereas I was using the same for both. Here's how I generate certificate and remove password from private key file (assuming you have exported .p12 files) :
Note the difference in the first two openssl commands.
我也有这个问题。对我来说,在删除 ssl 选项中“cipher”的显式设置后,它就起作用了:
所以在删除行后:“ciphers”=> “DES-CBC3-SHA”成功了。
I had this problem, too. For me it worked after removing the explicit setting of the 'cipher' in the ssl options:
so after removing the line: 'ciphers' => 'DES-CBC3-SHA' it worked.