菜鸟教程小白 发表于 2022-12-12 10:16:34

ios - Apple Push Notification 错误设置私钥


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

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

<blockquote>
<p>openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert
PushTestCert.pem -key PushTestKey.pem<br/>
Enter pass phrase for
PushTestKey.pem:<br/>
error setting private key<br/>
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:</p>
</blockquote>

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

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

<p>其他帖子都提示app p12错了,但是我怎么才能看到私钥是什么,为什么不匹配???</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您应该将您的 apns 证书作为单独的 cert/key pem 文件提供。并且您需要从 keypem 中删除密码。</p>

<p><strong>从 p12 中分离 pem 文件</strong></p>

<pre><code>openssl pkcs12 -clcerts -nokeys -out cert.pem -in cert.p12

openssl pkcs12 -nocerts -out key.pem -in key.p12
</code></pre>

<p><strong>从 pem 文件中删除密码</strong></p>

<pre><code>openssl rsa -in key.pem -out key-noenc.pem
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Apple Push Notification 错误设置私钥,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/35027302/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/35027302/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Apple Push Notification 错误设置私钥