仅出于开发目的,我试图强制 java 接受来自我们服务器的 SSL 证书。在 c# 中,我能够做到这一点:
public class MyPolicy : ICertificatePolicy
{
public bool CheckValidationResult(
ServicePoint srvPoint
, X509Certificate certificate
, WebRequest request
, int certificateProblem)
{
//Return True to force the certificate to be accepted.
return true;
} // end CheckValidationResult
} // class MyPolicy
并在连接到服务器之前实例化它:
System.Net.ServicePointManager.CertificatePolicy = new MyPolicy();
Java中是否有类似的解决方案?