gpt4 book ai didi

php - 使用 PEM 文件在 PHP 中推送通知

转载 作者:IT王子 更新时间:2023-10-28 23:56:30 25 4
gpt4 key购买 nike

我一直在阅读 Ray Wenderlich 关于使用 PHP 脚本推送通知的教程。

引用:http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1

http://www.raywenderlich.com/32963/apple-push-notification-services-in-ios-6-tutorial-part-2

我进行了大量研究,但在第 2 部分中遇到了一个问题,即使用 ck.pem 文件运行 push.php 文件。

/Applications/XAMPP/bin/php push.php 开发

我唯一的区别是我使用的是 XAMPP 而不是 MAMP。

我已确认所有扩展都已安装。

我可以通过这样做在终端中测试我的证书:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem

它要求我输入我的密码,我输入了。一切都在终端中成功运行。

但是,当我运行 push.php 文件时,出现以下错误:

PHP 警告:stream_socket_client():SSL 操作失败,代码为 1。OpenSSL 错误消息:错误:14090086:SSL 例程:SSL3_GET_SERVER_CERTIFICATE:证书验证失败PHP 警告:stream_socket_client():无法启用加密

PHP 警告:stream_socket_client():无法连接到第 140 行的 ssl://gateway.sandbox.push.apple.com:2195(未知错误)

php 文件中的第 140 行是:

$this->fp = stream_socket_client('ssl://' . $this->server, $err, $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);

我找到了这些:

iOS push notification does not work when using crontab scheduler

https://devforums.apple.com/message/1054840#1054840

Push notification in PHP

我真的重试了一切。我知道我的密码是正确的。我重新创建了我的证书、pem 文件和 key 。没有任何效果。每次我这样做都会出现同样的错误。

我很困惑。

有没有人有任何建议或知道发生了什么事?

谢谢!

更新 1:

我也试过设置 ck.pem 文件的完整路径,但也没有修复错误。

最佳答案

好吧,我终于明白了!经过2天的工作。

因此,对于遇到此问题的任何其他人:

从以下网址下载 entrust_2048_ca.cer 证书: https://www.entrust.com/get-support/ssl-certificate-support/root-certificate-downloads/

向下滚动并获取 Entrust.net 证书颁发机构 (2048)

然后,在 push.php 文件中,在设置密码上下文后,添加以下行:stream_context_set_option($ctx, 'ssl', 'cafile', 'entrust_2048_ca.cer');

关于php - 使用 PEM 文件在 PHP 中推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28221224/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com