2011-10-24 4 views
5

Dumb X509TrustManager 및 HostnameVerifier를 사용하여 Jersey RESTful 클라이언트를 작성하여 연구소 시스템의 모든 SSL 인증서를 신뢰함으로써 자체 서명 된 인증서를보다 쉽게 ​​처리 할 수 ​​있도록했습니다.CXF RESTful 클라이언트 - 모든 인증서를 신뢰하는 방법?

 ClientConfig config = new DefaultClientConfig(); 
     SSLContext context = null; 
     try 
     { 
      context = SSLContext.getInstance("SSL"); 
      context.init(null, 
        new TrustManager[] { new DumbX509TrustManager() }, 
        null); 
      config.getProperties() 
        .put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, 
          new HTTPSProperties(this.getHostnameVerifier(), 
            context)); 
      webClient = Client.create(config); 
     } 
     .... 

CXF를 사용하여 비슷한 작업을 수행 할 수있는 방법이 있습니까?

답변

6

이것은 CXF 메일 링리스트의 것입니다. 내가 인해 다른 시스템 업데이트에 구현하지 않았다는 것을 참고, 그래서 이것은 이론적 :

WebClient webClient = WebClient.create(this.serviceURL, 
    this.username, 
    this.password, 
    null); // Spring config file - we don't use this 

if (trustAllCerts) 
{ 
    HTTPConduit conduit = WebClient.getConfig(webClient) 
     .getHttpConduit(); 

    TLSClientParameters params = 
     conduit.getTlsClientParameters(); 

    if (params == null) 
    { 
     params = new TLSClientParameters(); 
     conduit.setTlsClientParameters(params); 
    } 

    params.setTrustManagers(new TrustManager[] { new 
     DumbX509TrustManager() }); 

    params.setDisableCNCheck(true); 
} 
+0

[이 대답은] (http://stackoverflow.com/a/6755459/150992)는 어떻게 수도 사항 인증서를 맹목적으로 받아들이는 더미 TrustManager를 설정합니다. (물론, 프로덕션 환경에서 그런 것을 사용하고 싶지는 않을 것입니다) – Eyal

관련 문제