用TLSv1.2调用`apache.commons.httpclient.HttpClient` 3.1

时间:2018-02-16 11:50:54

标签: java ssl networking tls1.2 apache-commons-httpclient

我正在使用org.apache.commons.httpclient.HttpClient 3.1调用SOAP服务器。这是我的代码片段:

    URL targetURL =
                    new URL(msgContext.getStrProp(MessageContext.TRANS_URL));



    HttpClient httpClient = new HttpClient(this.connectionManager);

    httpClient.getParams().setConnectionManagerTimeout(this.clientProperties.getConnectionPoolTimeout());

    HostConfiguration hostConfiguration = 
                    getHostConfiguration(httpClient, msgContext, targetURL);
    Credentials defaultcreds = new UsernamePasswordCredentials(msgContext.getUsername(), msgContext.getPassword());
    httpClient.getState().setCredentials(new AuthScope(msgContext.getStrProp(MessageContext.TRANS_URL), 80, AuthScope.ANY_REALM), defaultcreds);
    httpClient.getParams().setAuthenticationPreemptive(true);
    httpClient.executeMethod(hostConfiguration, method, null);

但是我得到javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake例外。

我试图通过创建一个不验证证书的信任管理器来修复它。但错误仍然存​​在。 有没有其他方法可以使用TLSv1.2或by-pass ssl security来调用它?

0 个答案:

没有答案