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

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

问题描述

我使用了著名的 Ray Wanderlich 的 php 脚本 教程 在开发阶段发送推送通知.在我创建 pem 文件(来自 p12 和 aps_development.cer 文件)并在 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 文件.我从 Keychain 导出了正确的 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天全站免登陆