使用CXF Spring配置的SSL安全Web服务客户端

时间:2013-04-26 20:21:52

标签: cxf

我需要使用CXF Spring配置创建SSL安全的Web服务客户端 我想知道如何告诉CXF使用我的密钥库中的客户端证书? 我需要在WEB-INF下创建cxf.xml文件吗? 如果是的话,我应该包含哪些内容?

我只需要客户端,因为服务器端是我连接的第三方提供商。

我的pom中有以下依赖项

 <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-frontend-jaxws</artifactId>
        <version>${cxf.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-rt-transports-http</artifactId>
        <version>${cxf.version}</version>
    </dependency>

谢谢!

2 个答案:

答案 0 :(得分:0)

我遇到了同样的问题,并没有找到配置它的弹簧方式。所以我做this

答案 1 :(得分:0)

http://cxf.apache.org/docs/client-http-transport-including-ssl-support.html#ClientHTTPTransport%28includingSSLsupport%29-ConfiguringSSLSupport

怎么样?
<http:conduit name="{http://apache.org/hello_world}HelloWorld.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>