【问题标题】:Let webservice use SSL让 webservice 使用 SSL
【发布时间】:2017-06-01 08:05:13
【问题描述】:

在 WildFly 8.2.1 中,我试图让现有的 web 服务 (JAX-WS) 使用 SSL,但我没有在快速入门中看到任何 SSL 的使用,而且我能够通过谷歌搜索的信息有限。到目前为止,我已将其添加到 web.xml:

<security-constraint>
    <display-name>Foo security</display-name>
    <web-resource-collection>
        <web-resource-name>FooService</web-resource-name>
        <url-pattern>/foo/FooService</url-pattern>
        <http-method>POST</http-method>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>CONFIDENTIAL</transport-guarantee>
    </user-data-constraint>
</security-constraint>

这是在我的standalone.xml中:

<subsystem xmlns="urn:jboss:domain:webservices:1.2">
   <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
   <endpoint-config name="Standard-Endpoint-Config"/>
   <endpoint-config name="Recording-Endpoint-Config">
   <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
   <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
   </pre-handler-chain>
   </endpoint-config>
   <client-config name="Standard-Client-Config"/>
</subsystem>

但显然这还不够;当我查看standalone/data/wsdl/foo.ear/foo.war/FooService/Bar.wsdl 时,我看到了:

<service name="FooService">
   <port binding="foowsb:FooBinding" name="FooBinding">
       <soap:address location="http://localhost:8080/foo/FooService"/>
   </port>
</service>

请注意,在 EAR/WAR 中,soap:address.location 仅填充了一个占位符(我认为该值被忽略)。

我找到了一些关于设置安全领域和使用 keytool 创建自签名证书的信息(我做过),但我完全想念应该如何将它们链接在一起。

我也尝试设置wsdl-uri-scheme=https,但仅在更高版本的 CXF 中支持。

【问题讨论】:

标签: ssl wsdl jax-ws wildfly wildfly-8


【解决方案1】:

似乎soap:address.location 值在被替换时不会被忽略,因为将其从REPLACE_WITH_ACTUAL_URL 更改为https://REPLACE_WITH_ACTUAL_URL 就成功了——现在该服务在https://localhost:8443 上暴露了。

我还需要在standalone.xml 中执行几个步骤:在undertow 中添加https-listener

<https-listener name="secure" socket-binding="https" security-realm="SslRealm"/>

定义 SslRealm:

<security-realm name="SslRealm">
   <server-identities>
      <ssl>
         <keystore path="foo.keystore" relative-to="jboss.server.config.dir" keystore-password="foo1234" alias="foo" key-password="foo1234"/>
      </ssl>
   </server-identities>
   <authentication>
      <truststore path="foo.truststore" relative-to="jboss.server.config.dir" keystore-password="foo1234"/>
   </authentication>
</security-realm>

请注意,我在这里为服务器和客户端重用了相同的密钥库。由于我的客户端在开发过程中是同一个 WF 节点中的 ATM,因此我也必须在那里设置客户端部分:

<system-properties>
    <property name="javax.net.ssl.trustStore" value="${jboss.server.config.dir}/foo.keystore"/>
    <property name="javax.net.ssl.trustStorePassword" value="foo1234"/>
    <property name="org.jboss.security.ignoreHttpsHost" value="true"/>
</system-properties>

在 WF 9+ 中,最后一个属性应替换为 cxf.tls-client.disableCNCheck

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-11-13
    • 2013-01-29
    • 2017-10-27
    相关资源
    最近更新 更多