OGeek|极客世界-中国程序员成长平台

标题: ios - Apple Push Notification 错误设置私钥 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 10:16
标题: ios - Apple Push Notification 错误设置私钥

我一直在努力为我的应用正确设置推送通知证书。该应用程序已经在商店中,所以我不能像其他人遇到此问题的解决方案那样只是“重新开始”生成文件!

我以这篇文章为例来创建证书:http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1#comments .当我开始测试我生成的内容时,我得到:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushTestCert.pem -key PushTestKey.pem
Enter pass phrase for PushTestKey.pem:
error setting private key
4368:error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch:/SourceCache/OpenSSL098/OpenSSL098-35.1/src/crypto/x509/x509_cmp.c:406:

该示例显示了 Keychain Access 的 Keys 部分中的应用程序。我的应用程序在那里,但在私钥下它有一个证书(我的 iPhone 开发者证书)。我需要将这两个项目都导出到我的 p12 中,还是只需要导出私钥?

我已尝试下载 aps_development.cer 并将其转换为 pem 并从 Keychain Access 创建 cert pem,但均未成功。

其他帖子都提示app p12错了,但是我怎么才能看到私钥是什么,为什么不匹配???



Best Answer-推荐答案


您应该将您的 apns 证书作为单独的 cert/key pem 文件提供。并且您需要从 key pem 中删除密码。

从 p12 中分离 pem 文件

openssl pkcs12 -clcerts -nokeys -out cert.pem -in cert.p12

openssl pkcs12 -nocerts -out key.pem -in key.p12

从 pem 文件中删除密码

openssl rsa -in key.pem -out key-noenc.pem

关于ios - Apple Push Notification 错误设置私钥,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35027302/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4