通过php脚本发送iOS通知:'无法设置私钥文件' [英] Sending iOS notification through a php script: 'Unable to set private key file'

查看:48
本文介绍了通过php脚本发送iOS通知:'无法设置私钥文件'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了著名的Ray Wanderlich的php脚本

I have used the php script from the well known Ray Wanderlich tutorial to send push notifications during development phase. They were triggered properly after I created the pem file (from the p12 and aps_development.cer file) and mentioned the device token in the php script.

但是,当我使用包含生产p12和aps_production.cer文件的pem文件时,通知甚至没有到达APNS服务器.它在本地服务器端本身显示以下错误.

However, when I am using a pem file which has production p12 and aps_production.cer file, the notification is not even reaching the APNS server. It is showing the below error at the local server end itself.

Unable to set private key file `/Users/administrator/Desktop/SimplePush/ck.pem' in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

Warning: stream_socket_client(): failed to create an SSL handle in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

Warning: stream_socket_client(): Failed to enable crypto in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

Warning: stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Unknown error) in /Users/administrator/Desktop/SimplePush/simplepush.php on line 22

可能是什么原因.p12文件没有任何密码(尽管我已经为pem文件配置了密码),这就是在php脚本中给出的密码.

What could be the reason for it. The p12 file does not have any password (though I have configured a password for the pem file) and this is how it has been given in the php script.

// Put your private key's passphrase here:
$passphrase = '';

推荐答案

它不是正确的p12文件.我从钥匙串中导出了正确的p12文件,效果很好.

It was not the correct p12 file. I exported the correct p12 file from Keychain and it went well.

经验教训-

  1. 如果您使用的p12和cer文件彼此不对应,那么显然在创建串联的pem文件时不会显示任何错误.但是执行脚本时,将显示错误.

  1. If the p12 and cer files you are using do not correspond to each other, obviously there wouldn't be any error shown during the concatenated pem file creation. But when you execute the script, there will be an error shown.

上面的错误消息不一定表示p12文件的密码短语不正确.它们也可能意味着p12文件与使用的cer文件不对应.

The above error messages do not necessarily imply that the p12 file's passphrase is incorrect. They may also mean that the p12 file does not correspond to the used cer file.

这篇关于通过php脚本发送iOS通知:'无法设置私钥文件'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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