我正在尝试使用以下代码绕过证书:
私有静态 HttpClient wrapClient(HttpClient base) 抛出 AGException { 尝试 { SSLContext ctx = SSLContext.getInstance("TLS");
X509TrustManager tm = new X509TrustManager()
{
public void checkClientTrusted(X509Certificate[] xcs, String string) throws CertificateException
{
}
public void checkServerTrusted(X509Certificate[] xcs, String string) throws CertificateException {
}
public X509Certificate[] getAcceptedIssuers() {
return null;
}
};
ctx.init(null, new TrustManager[] { tm }, null);
SSLSocketFactory ssf = new SSLSocketFactory(ctx,SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
ClientConnectionManager ccm = base.getConnectionManager();
SchemeRegistry sr = ccm.getSchemeRegistry();
sr.register(new Scheme("https", 443, ssf));
return new DefaultHttpClient(ccm, base.getParams());
}
catch (NoSuchAlgorithmException nsaex)
{
throw new AGException(nsaex, "Not able to get the SSL Context");
}
catch (KeyManagementException kmex) {
throw new AGException(kmex, "Not able to get the SSL Context");
}
}
但仍然收到以下错误 javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated
简单介绍一下我的任务:
我正在使用腻子隧道到服务器并通过 https 调用进行 SOAP 以连接到该服务器,但即使尝试使用上述代码也会收到相同的错误。
任何帮助/建议都会非常有用。提前致谢。
-尼什