菜鸟教程小白 发表于 2022-12-13 07:50:46

ios - 为什么我的服务器证书被拒绝?


                                            <p><p>我正在尝试使用 TLS 1.2 将我的应用程序连接到服务器。服务器正在使用已由设备上已安装的自签名 CA 证书签名的证书(我将 CA 证书通过电子邮件发送给自己,点击它。现在它显示在“设置”->“常规”->“配置文件”下)。这以前在我的应用程序中工作,但我们已经更改了我们正在使用的 CA 证书,所以我也更新了服务器的证书。现在我遇到 SSL 故障。</p>

<p>我看到的错误是 <code>errSSLXCertChainInvalid</code> 来 self 在客户端上对 <code>SSLHandshake</code> 的调用。据我所知,服务器证书应该是有效的。 <code>openssl verify -CAfile ca-cert.pem server-cert.pem</code> 返回<code>OK</code>,并且那个 ca-cert.pem 就是我在设备上安装的同一个 CA 证书.</p>

<p>有什么想法吗?谢谢!</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>苹果的<a href="https://developer.apple.com/library/mac/documentation/security/Reference/secureTransportRef/Reference/reference.html" rel="noreferrer noopener nofollow">documentation</a>有一些信息关于这个错误:</p>

<blockquote>
<p><code>errSSLXCertChainInvalid</code> — The peer has an invalid certificate chain; for example, signature verification within the chain failed, or no certificates were found.</p>
</blockquote>

<p>如果你使用 <code>SSLSetPeerDomainName</code>:</p>

<blockquote>
<p>You can use this function to verify the common name field in the peer’s certificate. If you call this function and the common name in the certificate does not match the value you specify in the peerName parameter, then handshake fails and returns errSSLXCertChainInvalid.</p>
</blockquote>

<p>我建议卸载您的设备配置文件,然后创建一个新的。</p>

<p>此外,最好检查一下您是否可以从 Web 浏览器等无错误地访问服务器。这将显示证书是否有问题,或者只是您的 iOS 设备上的配置文件有问题。</p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 为什么我的服务器证书被拒绝?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/23689098/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/23689098/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 为什么我的服务器证书被拒绝?