小编Tom*_*nus的帖子

Apache HttpClient 4.3和x509客户端证书进行身份验证

现在我正在寻找有关如何通过HttpComponentsMessageSender(不相关)重写客户端x509证书身份验证的弃用解决方案的任务的解决方案.

例如,弃用的解决方案是:

    SSLSocketFactory lSchemeSocketFactory = new SSLSocketFactory(this.keyStore, this.keyStorePassword);
    Scheme sch = new Scheme("https", 443, lSchemeSocketFactory);

    DefaultHttpClient httpClient = (DefaultHttpClient)getHttpClient();
    httpClient.getConnectionManager().getSchemeRegistry().register(sch);
Run Code Online (Sandbox Code Playgroud)

作为我使用的CloseableHttpClient的新解决方案:

    SSLContextBuilder sslContextBuilder = SSLContexts.custom()
            // this key store must contain the key/cert of the client
            .loadKeyMaterial(keyStore, keyStorePassword.toCharArray());

    if (trustStore != null) {
        // this key store must contain the certs needed and trusted to verify the servers cert
        sslContextBuilder.loadTrustMaterial(trustStore);
    }

    SSLContext sslContext = sslContextBuilder.build();

    LayeredConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);

    // Create a registry of custom connection socket factories for …
Run Code Online (Sandbox Code Playgroud)

java ssl spring-ws httpclient x509certificate

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

httpclient ×1

java ×1

spring-ws ×1

ssl ×1

x509certificate ×1