我正在尝试在我的应用中执行推送通知并关注此链接 http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12
我的系统已经成功连接到telnet但是当我输入查询连接ssl证书和私钥时发现错误
$ openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert apns-dev-cert.pem -key apns-dev-key.pem
unable to load client certificate private key file
1301:error:0906D06C:PEM routines:PEM_read_bio:no start line:/SourceCache/OpenSSL098/OpenSSL098-44/src/crypto/pem/pem_lib.c:648:Expecting: ANY PRIVATE KEY
任何人都可以告诉我什么类型的错误以及它的解决方案是什么?
提前致谢
答案 0 :(得分:14)
起初我也面临着这个问题。
我们有两个文件
1)一个是来自苹果的aps_development.cer
2)另一个来自keychain access
,其中包含我们刚创建的通用名称。
之后,将它们都转换为.pem
个文件。
例如,cert.pem
和key.pem
。
之后,使用以下命令
cat cert.pem key.pem > ck.pem
首先我使用下面的命令打开。
openssl s_client -connect gateway.sandbox.push.apple.com:2195
-cert cert.pem -key key.pem
这会让我回答你提到的错误。 之后我尝试使用
openssl s_client -connect gateway.sandbox.push.apple.com:2195
-cert cert.pem -key ck.pem
然后它已经工作了。希望这可以帮助。
答案 1 :(得分:13)
以下命令足以验证密钥/证书:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert push_development.pem
关键部分是从Keychain Access导出.p12时同时选择证书和私钥(系统会要求您提供3个密码,一个用于.p12一个用于证书,一个用于私钥。)
要将.p12转换为.pem,请按照Apple:
中的说明操作openssl pkcs12 -in CertificateName.p12 -out CertificateName.pem -nodes
答案 2 :(得分:6)
我在为Enterprise Distribution生成PEM文件时遇到了同样的问题,但后来我发现我针对 iPhone分发证书生成了一个p12文件虽然我应该针对 Apple Production iOS Push Servies 键生成p12。如果任何人使用了分发密钥,希望这可以解决问题。
答案 3 :(得分:3)
您好请按照以下命令操作。
步骤1
openssl pkcs12 -clcerts -nokeys -out developer_key.pem -in developer_key.p12
注意:只需在终端上拖动文件路径...
第二步
openssl pkcs12 -nocerts -out apns_key.pem -in apns_key.p12
步骤3
openssl pkcs12 -in developer_key.p12 -out developer_key.pem -nodes -clcerts
步骤4
openssl pkcs12 -in apns_key.p12 -out apns_key.pem -nodes -clcerts
第5步
cat apns_key.pem developer_ket.pem >developer.pem
为分发证书做同样的步骤
创建developer.pem和distribution.pem
之后请同时验证以下命令中的文件。
第六步
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert developer.pem -debug -showcerts -CAfile "Entrust.net.Certification Authority (2048).pem
答案 4 :(得分:2)
通知密码短语必须超过3个字符。
我刚刚修正了短语 1234 :D