通过发送一个PHP脚本的iOS通知:“无法设置专用密钥文件” [英] Sending iOS notification through a php script: 'Unable to set private key file'

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

问题描述

我从著名的雷Wanderlich <一个用PHP脚本href=\"http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1\">tutorial在开发阶段发送推送通知。他们正确触发我创建了PEM文件(从P12和aps_development.cer文件)后提到的PHP脚本设备令牌。

然而,当我使用有生产P12和aps_production.cer文件PEM文件,通知,甚至没有达到APNS服务器。它显示在本地服务器本身到底下面的错误。

 无法设置专用密钥文件'/Users/administrator/Desktop/SimplePush/ck.pem在/Users/administrator/Desktop/SimplePush/simplepush.php第22行警告:在stream_socket_client():未能在/Users/administrator/Desktop/SimplePush/simplepush.php第22行创建一个SSL手柄警告:在stream_socket_client():失败,使加密在/Users/administrator/Desktop/SimplePush/simplepush.php第22行警告:在stream_socket_client():无法连接到SSL:在/Users/administrator/Desktop/SimplePush/simplepush.php 2195(未知错误)在第22行://gateway.push.apple.com

可能是什么的原因吧。该P12文件没有任何密码(虽然我已经配置了PEM文件的密码),这是它是如何在PHP脚本已发出。

  //把你的私钥的密码在这里:
$密码='';


解决方案

这不是正确的P12文件。我从钥匙扣导出正确的P12文件,并将其顺利。

吸取的教训 -


  1. 如果您使用的是P12和CER文件不相互对应,显然不会有串联的PEM文件创建过程中表现出任何错误。但是,当你执行脚本,会出现显示错误。


  2. 上面的错误消息并不一定意味着P12文件的密码不正确。他们还可能意味着,P12文件不对应于所使用的CER的文件


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.

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

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 = '';

解决方案

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

Lessons learnt -

  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.

  2. 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天全站免登陆