Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如何将我的设置HttpsURLConnection为仅信任特定证书?目前我的代码设置为信任所有证书。但要求是只信任一个特定的证书而不信任其他证书。我怎样才能在Java中做到这一点?我正在使用 JDK 1.5。
HttpsURLConnection
您可以通过创建自定义 SSLSocketFactory 并提供您自己的 TrustManager 来信任特定证书。看...
通过 HTTPS 使用 HttpClient 信任所有证书
和
如何在特定连接上使用不同的证书?
在您的 TrustManager 中,您将收到来自客户端/服务器的证书链,以根据您的特定证书进行验证。
将其导入您的客户端信任库。