인증 이제 HttpComponentsMessageSender (관련 없음)를 통해 클라이언트 측 x509 인증서 인증을 위해 사용되지 않는 솔루션을 다시 작성하는 방법에 대한 해결책을 찾고 있습니다.Apache HttpClient 4.3 및 x509 클라이언트 인증서
예를 들어, 사용되지 않는 솔루션입니다 : CloseableHttpClient 새로운 솔루션은 내가 사용하고
SSLSocketFactory lSchemeSocketFactory = new SSLSocketFactory(this.keyStore, this.keyStorePassword);
Scheme sch = new Scheme("https", 443, lSchemeSocketFactory);
DefaultHttpClient httpClient = (DefaultHttpClient)getHttpClient();
httpClient.getConnectionManager().getSchemeRegistry().register(sch);
으로 :
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 supported
// protocol schemes/https
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", sslsf)
.register("http", new PlainConnectionSocketFactory())
.build();
PoolingHttpClientConnectionManager connPoolControl =
new PoolingHttpClientConnectionManager(socketFactoryRegistry);
setConnPoolControl(connPoolControl);
getClientBuilder().setSSLSocketFactory(sslsf);
는 여전히 403 서버에서 금지 얻을. 그러나 "deprecated"버전의 솔루션을 사용하면 멋지게 작동합니다. SSL 인증서에 서명 됨 Thawte.
아이디어가 있으십니까? 감사
'SSLContexts 유형은 더 이상 사용되지 않으며'생성자 SSLConnectionSocketFactory (SSLContext, X509HostnameVerifier)는 사용되지 않습니다' – KCD
TLS는 이미 기본 프로토콜이므로'useTLS()'는 쓸모가 없습니다. – herau
@KCD 감사합니다. 귀하의 의견에 따라 변경했습니다. – Daniyar