推送通知错误:“无法设置本地证书链文件”
我编写了一个测试 php 页面,该页面仅发送通用推送通知,并且它间歇性地工作。有时它会传递消息,有时我会收到此错误:
“消息:stream_socket_client() [function.stream-socket-client]:无法设置本地证书链文件`/var/www/ninerobot.com/public/mlb/ certs/mlbtr-push-dev.pem'; 检查您的 cafile/capath 设置是否包含您的证书及其颁发者的详细信息”
您知道如何解决此问题吗?
我在 Apple 的文档中看到它说“注意:要与 APN 建立 TLS 会话,必须在提供商的服务器上安装 Entrust Secure CA 根证书。如果服务器运行 Mac OS X,则此根证书已在钥匙串中在其他系统上,该证书可能不可用。”这是否意味着我需要做些什么?
I wrote a test php page that just sends out a generic push notification and it works intermittently. Sometimes it delivers the message and other times I get this error:
"Message: stream_socket_client() [function.stream-socket-client]: Unable to set local cert chain file `/var/www/ninerobot.com/public/mlb/certs/mlbtr-push-dev.pem'; Check that your cafile/capath settings include details of your certificate and its issuer"
Do you know how I can solve this issue?
I see that on Apple's docs it says "Note: To establish a TLS session with APNs, an Entrust Secure CA root certificate must be installed on the provider’s server. If the server is running Mac OS X, this root certificate is already in the keychain. On other systems, the certificate might not be available. You can download this certificate from the Entrust SSL Certificates website." Does this mean anything that I need to do?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我也需要付出更多的努力才能做到同样的事情。最终我找到了通过 PHP 全局 url 发送推送通知的解决方案。尝试以下步骤。在此之前,我希望大家都知道生成 3 个证书,即 PushChat.certSigningRequest、pushkey.p12 和aps_development.cer (csr,p12,cer)
打开终端并逐步运行以下命令:
然后最后将 SimplePush.php 移动到 ApnsDev.pem 文件位置。两个文件将位于同一文件夹中。并更改设备令牌、密码短语、证书名称(ApnsDev.pem)、消息... 在 simplepush.php 中使用以下 URL 下载文件。
http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip< /强>
然后在终端或域服务器中执行该文件
,或者
就是这样,推送通知将飞行并到达特定的 IOS 设备。
如果您想发送“徽章”,请更改 simplepush.php 中的有效负载代码,如下所示,
现在再次运行 php 文件,应用程序图标将出现,徽章编号以红色圆圈显示。
Me too got more struggle to do the same. Eventually I found solution to send push notification through PHP global url. Try the below steps. Before that I hope you all know to generate the 3 certificates thats PushChat.certSigningRequest, pushkey.p12 & aps_development.cer (csr,p12,cer)
Open your Terminal and step by step run the below commands:
Then Finally move the SimplePush.php to the ApnsDev.pem file location. Both files will be in same folder. and change Device Token, Pass Phrase, Certificate Name(ApnsDev.pem), Message… In simplepush.php Download the file using the below URL.
http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip
Then execute the file in terminal or your domain server
or
Thats it, the push notification will fly and reach the specific IOS device.
If you want to send 'Badge' then change the payload code in simplepush.php like below,
Now run the php file again and the app icon appears with badge number in red circle.
使用此清单来解决此问题:
Use this checklist to work through this:
除了 Steve N 的精彩回答之外,我还要补充最后一点。
issuer=
、subject=
等,并且您的文件以-----BEGIN 开头证书。在转换证书文件期间,它可能会被意外删除。
In addition to a great answer of Steve N let me add the last point.
issuer=
,subject=
etc. and your file begins with-----BEGIN CERTIFICATE
. It can be accidentally deleted during conversion of the certificate file.可能与OP的Q无关,但我尝试了所有带有不同标志的openssl语句,同时尝试与PHP
\SoapClient(... )
三天后我终于找到了一个适合我的解决方案。发帖以便下一个家伙(tte)可能会发现这比我更容易。GitBash
首先,您必须输入
YOUR_CERT_PASSWORD
一次,然后输入DIFFERENT_PASSWORD!
两次。后者可能可供所有有权访问代码的人使用。PHP
Might be irrelevant for OP's Q, but I've tried all openssl statements with all the different flags, while trying to connect with PHP
\SoapClient(...)
and after 3 days I finally found a solution that worked for me. Posting so the next dude(tte) may find this easier than me.GitBash
First you have to enter
YOUR_CERT_PASSWORD
once, thenDIFFERENT_PASSWORD!
twice. The latter will possibly be available to everyone with access to code.PHP