0
忽略它之后,我用下面的代码试图绕过证书:获得SSL错误,甚至使用的TrustManager
私有静态HttpClient的wrapClient(HttpClient的基地)抛出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:同行不认证
就向大家介绍我的分配新建分配FY:
我使用腻子隧道到服务器并通过https调用SOAP来连接到该服务器 ,但即使尝试使用上述代码也会收到相同的错误。
任何帮助/ suggesstions将非常appricates。 在此先感谢。
-Nitish
当你说peer,这意味着客户端或服务器? 在我的情况下,我没有在我身边使用任何证书,正如我所提到的,我想忽略在我身边使用任何证书。 总而言之,我想调用一个安全服务器(https呼叫)忽略握手,并为此使用上面的代码。 如果您可以共享正确的代码或告诉我的代码中要更改的位置,这将非常有帮助。 在此先感谢。 – Nitish 2013-04-22 19:54:00
当我说'同辈'时,我指的是电线另一端的那个人。 – EJP 2013-04-24 10:31:50