推送通知错误:“无法设置本地证书链文件" [英] Push Notification Error: "Unable to set local cert chain file"

查看:15
本文介绍了推送通知错误:“无法设置本地证书链文件"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一个测试 php 页面,它只发送一个通用的推送通知,它间歇性地工作.有时它会传递消息,有时我会收到此错误:

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:

"消息:stream_socket_client() [function.stream-socket-client]:无法设置本地证书链文件`/var/www/ninerobot.com/public/mlb/certs/mlbtr-push-dev.pem'; 检查您的 cafile/capath 设置是否包括您的证书及其颁发者的详细信息"

"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?

我在 Apple 的文档上看到它说注意:要与 APNs 建立 TLS 会话,必须在提供商的服务器上安装 Entrust Secure CA 根证书.如果服务器运行的是 Mac OS X,则此根证书已经存在在钥匙串中.在其他系统上,证书可能不可用.您可以从 Entrust SSL 证书网站下载此证书."这是否意味着我需要做些什么?

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?

推荐答案

我也遇到了同样的问题.最终我找到了通过 PHP 全局 url 发送推送通知的解决方案.请尝试以下步骤.在此之前,我希望你们都知道生成 3 个证书,即 PushChat.certSigningRequest、pushkey.p12 &aps_development.cer (csr,p12,cer)

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:

# Make sure terminal refers your correct certificate path.
$ cd ~/Desktop/

# Ask system administrator to open if its not connected 
$ telnet gateway.sandbox.push.apple.com 2195

Trying 17.110.227.35...
Connected to gateway.sandbox.push-apple.com.akadns.net.

Escape character is '^]'.

# Convert .cer to .pem
$ openssl x509 -in aps_development.cer -inform der -out PushCert.pem

# Convert .p12 to .pem. Enter your pass pharse which is the same pwd that you have given while creating the .p12 certificate. PEM pass phrase also same as .p12 cert.  
$ openssl pkcs12 -nocerts -out PushKey1.pem -in pushkey.p12

Enter Import Password:

MAC verified OK

Enter PEM pass phrase:

Verifying - Enter PEM pass phrase:

# To remove passpharse for the key to access globally. This only solved my stream_socket_client() & certificate capath warnings.
$ openssl rsa -in PushKey1.pem -out PushKey1_Rmv.pem

Enter pass phrase for PushChatKey1.pem:

writing RSA key

# To join the two .pem file into one file:
$ cat PushCert.pem PushKey1_Rmv.pem > ApnsDev.pem

然后最后将 SimplePush.php 移动到 ApnsDev.pem 文件位置.这两个文件将在同一个文件夹中.并更改设备令牌、密码短语、证书名称(ApnsDev.pem)、消息...在 simplepush.php 中使用以下 URL 下载文件.http://d1xzuxjlafny7l.cloudfront.net/downloads/SimplePush.zip然后在终端或您的域服务器中执行该文件

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

$ php simplepush.php

www.Domainname.com/push/simplepush.php  // Now, url shows 'Connected to APNS Message successfully delivered'.

就是这样,推送通知会飞并到达特定的 IOS 设备.

Thats it, the push notification will fly and reach the specific IOS device.

如果你想发送Badge",那么在 simplepush.php 中更改有效负载代码,如下所示,

If you want to send 'Badge' then change the payload code in simplepush.php like below,

// Construct the notification payload body:

$badge = 1;

$sound = 'default';

$body = array();

$body['aps'] = array('alert' => $message);

if ($badge)

    $body['aps']['badge'] = $badge;

if ($sound)

    $body['aps']['sound'] = $sound;


// End of Configurable 

// Encode the payload as JSON:

$payload = json_encode($body);

现在再次运行 php 文件,应用程序图标会出现,并带有红色圆圈中的徽章编号.

Now run the php file again and the app icon appears with badge number in red circle.

这篇关于推送通知错误:“无法设置本地证书链文件"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆