Java CXF客户端:找不到请求目标的有效证书路径

Java CXF客户端:找不到请求目标的有效证书路径,java,spring,web-services,ssl,cxf,Java,Spring,Web Services,Ssl,Cxf,我正在尝试为我也编写的基于CXF的web服务实现一个客户机 我的web服务工作得很好(通过soapUI测试工作正常),但运行客户端失败,原因如下: Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification

我正在尝试为我也编写的基于CXF的web服务实现一个客户机

我的web服务工作得很好(通过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)
消息明确指出了证书问题,因此我进行了快速搜索,找到了正确的方法,并将以下内容添加到我的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>
所以我做了一个快速搜索,发现这表明:

客户端需要使用 包含STS的证书,例如:


这加强了@greybearedgeek所写的内容。现在开始…

问题解决了

我仔细地遵循(注意“旧版java”上的亮点,以及默认密码“changeit”),将以下内容导入java的受信任证书列表:

还有一个非常重要的附加的扭曲:对链中的所有证书执行此操作,而不仅仅是根证书(在我的例子中有三个:我的组织、中间组织和根组织)


然后。。。转到Spring应用程序上下文配置XML并修改
,您遗漏的是您需要指向一个有效的信任库,该信任库具有与服务器证书匹配的有效证书。@greybearedgeek谢谢。你的意思是,除非我提供有效的信任库,并提供与服务器证书匹配的有效证书,否则生成/编译的代码将处理
否,我的意思是你的管道指定了一个信任库,因此信任库必须包含服务器的证书,以及到信任证书的有效证书链,否则,您将得到您得到的错误。@greybearedgeek我现在将尝试您的建议(请参阅上面的更新)。我做这项兼职工作,所以我需要一些时间才能根据新的见解采取行动。谢谢你的帮助。@greybearedgeek好的,我终于从头开始构建了一个完整的信任库,包含了整个证书链并包含在客户机的JAR中,但这根本没有帮助,发出了同样的错误。我觉得方向不对。现在的问题是我如何从这里开始?
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>
<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>