我正在尝试实现一个基于CXF的Web服务客户端,这个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)
这条消息明显指向了一个证书问题,所以我进行了快速搜索,并找到了正确的方法来 支持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.
所以我进行了快速搜索,并找到了一个建议的线程,链接如下:a thread:
客户端需要使用包含 STS 证书的密钥库来配置 HTTP 传输通道,例如:
<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所写的内容。现在要去处理这个问题...
pom.xml
中的<http:conduit
部分视为从未放置在那里? - Withheld