복붙노트

[SPRING] CXF 클라이언트 : 요청한 대상에 대한 유효한 인증 경로를 찾을 수 없습니다.

SPRING

CXF 클라이언트 : 요청한 대상에 대한 유효한 인증 경로를 찾을 수 없습니다.

내가 작성한 CXF 기반 웹 서비스 용 클라이언트를 구현하려고합니다.

내 웹 서비스는 훌륭하게 작동하지만 (soapUI를 통해 잘 작동 함) 클라이언트를 실행하는 데는 다음과 같은 문제가 있습니다.

Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
        at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:323)

이 메시지는 인증서 문제를 분명하게 지적하므로 CXF에서 SSL을 지원하는 정확한 접근법을 발견하고 Spring 애플리케이션 컨텍스트 설정 XML에 다음을 추가했다.

  <http:conduit name="https://myserver/myws/register/soap?wsdl:{http://glob.reg.com/myws}.http-conduit">

    <http:tlsClientParameters>
      <sec:keyManagers keyPassword="password">
        <sec:keyStore type="JKS" password="password"
                      file="my/file/dir/Morpit.jks"/>
      </sec:keyManagers>
      <sec:trustManagers>
        <sec:keyStore type="JKS" password="password"
                      file="my/file/dir/Truststore.jks"/>
      </sec:trustManagers>
      <sec:cipherSuitesFilter>
        <!-- these filters ensure that a ciphersuite with
             export-suitable or null encryption is used,
             but exclude anonymous Diffie-Hellman key change as
             this is vulnerable to man-in-the-middle attacks -->
        <sec:include>.*_EXPORT_.*</sec:include>
        <sec:include>.*_EXPORT1024_.*</sec:include>
        <sec:include>.*_WITH_DES_.*</sec:include>
        <sec:include>.*_WITH_AES_.*</sec:include>
        <sec:include>.*_WITH_NULL_.*</sec:include>
        <sec:exclude>.*_DH_anon_.*</sec:exclude>
      </sec:cipherSuitesFilter>
    </http:tlsClientParameters>
    <http:authorization>
      <sec:UserName>Betty</sec:UserName>
      <sec:Password>password</sec:Password>
    </http:authorization>
    <http:client AutoRedirect="true" Connection="Keep-Alive"/>

  </http:conduit>

그리고 클라이언트를 다시 빌드하십시오. 클라이언트가 성공적으로 구축되었지만이 http : conduit을 추가 한 적이없는 것처럼 동일한 정확한 오류와 똑같은 스택 추적을 얻고 있습니다.

저장소에 인증서를 아직 추가하지 않았으며 저장소 경로가 잘못되었지만 새 http : conduit 정보에 맞게 다시 작성된 클라이언트가이 문제를보고하는 방식을보고 싶었 기 때문에 고의적이었습니다.

대신, 나는 그것이 모두 무시 된 것을보고 놀랐다.

나는 무엇을 놓쳤는가?

이것을 접근하는 올바른 방법은 무엇입니까?

업데이트 : 방금 내 applicationcontext.xml 밑줄이 http : conduit이 오류 메시지와 함께 나타났습니다 :

The prefix "http" for element "http:conduit" is not bound.

따라서 빠른 검색을 수행하고 제안하는 스레드를 발견했습니다.

 <http:conduit name="https://localhost:.*">
      <http:tlsClientParameters disableCNCheck="true">
        <sec:trustManagers>
          <sec:keyStore type="jks" password="cspass" resource="clientstore.jks"/>
        </sec:trustManagers>
      </http:tlsClientParameters>
  </http:conduit>

@GreyBeardedGeek이 쓴 글을 강화합니다. 지금이 일을하려고 ...

해결법

  1. ==============================

    1.문제 해결됨!

    문제 해결됨!

    필자는이 magicmonster 기사를 신중하게 ( "이전 버전의 Java"및 기본 비밀번호 'changeit'의 하이라이트에 주목하여) 전체 자체 서명 된 인증서 체인을 Java의 신뢰할 수있는 인증서 목록으로 가져옵니다.

    http://magicmonster.com/kb/prg/java/ssl/pkix_path_building_failed.html

    매우 중요한 추가 트위스트가 있습니다 : 루트뿐만 아니라 체인의 모든 인증서에 대해 수행하십시오! (내 경우에는 세 가지가 있습니다 : 조직, 중급 및 근원)

    그런 다음 Spring 애플리케이션 컨텍스트 config XML로 가서

    <http:tlsClientParameters>
      <sec:keyManagers keyPassword="changeit">
        <sec:keyStore type="JKS" password="changeit"
                      file="C:\Program Files (x86)\Java\jdk1.6.0_45\jre\lib\security\cacerts"/> 
      </sec:keyManagers>
      <sec:trustManagers>
        <sec:keyStore type="JKS" password="changeit"
                      file="C:\Program Files (x86)\Java\jdk1.6.0_45\jre\lib\security\cacerts"/> 
      </sec:trustManagers>
    
  2. from https://stackoverflow.com/questions/20554567/cxf-client-unable-to-find-valid-certification-path-to-requested-target by cc-by-sa and MIT license