服务器脚本中的 APN 错误

发布于 2024-08-11 23:59:34 字数 888 浏览 3 评论 0原文

我在发送有效负载数据时在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

我的黑色迷你裙 2024-08-18 23:59:34

您可以发布用于连接 APN 的 PHP 代码 (push.php) 吗?

一些在黑暗中拍摄的照片:
- 证书和私钥都在该 .pem 文件中吗?
- 您是否从私钥文件中删除了密码,或者您是否在 PHP 代码中正确设置了密码?
- 运行脚本的用户是否具有访问/读取证书/密钥文件的适当 unix 权限?
- 您可以从您的机器访问Apple的服务器吗?您可以通过运行 telnet 进行测试。

telnet gateway.sandbox.push.apple.com 2195

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.

telnet gateway.sandbox.push.apple.com 2195
所有深爱都是秘密 2024-08-18 23:59:34

我遇到了这个问题,密钥生成过程是问题所在,证书和密钥文件有两个不同的 openssl 命令,而我对两者都使用相同的命令。以下是我生成证书并从私钥文件中删除密码的方法(假设您已导出 .p12 文件):

openssl pkcs12 -clcerts -nokeys -out aps-dev-cert.pem -in aps-dev-cert.p12
openssl pkcs12 -nocerts -out aps-dev-key.pem -in aps-dev-key.p12
openssl rsa -in aps-dev-key.pem -out aps-dev-key.unencrypted.pem
cat aps-dev-cert.pem aps-dev-key.unencrypted.pem > aps-dev.pem

请注意前两个 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) :

openssl pkcs12 -clcerts -nokeys -out aps-dev-cert.pem -in aps-dev-cert.p12
openssl pkcs12 -nocerts -out aps-dev-key.pem -in aps-dev-key.p12
openssl rsa -in aps-dev-key.pem -out aps-dev-key.unencrypted.pem
cat aps-dev-cert.pem aps-dev-key.unencrypted.pem > aps-dev.pem

Note the difference in the first two openssl commands.

﹉夏雨初晴づ 2024-08-18 23:59:34

我也有这个问题。对我来说,在删除 ssl 选项中“cipher”的显式设置后,它就起作用了:

$context_options = [ 
    'ssl' => [ 
        'local_cert' => ..., 
        'passphrase' => ..., 
        'ciphers' => 'DES-CBC3-SHA'
    ] 
]; 
stream_context_set_option($stream_context, $context_options);

所以在删除行后:“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:

$context_options = [ 
    'ssl' => [ 
        'local_cert' => ..., 
        'passphrase' => ..., 
        'ciphers' => 'DES-CBC3-SHA'
    ] 
]; 
stream_context_set_option($stream_context, $context_options);

so after removing the line: 'ciphers' => 'DES-CBC3-SHA' it worked.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文