代码之家  ›  专栏  ›  技术社区  ›  Kris Swat

Spring集成WS出站网关SSL

  •  0
  • Kris Swat  · 技术社区  · 6 年前

    我们有一个外部SOAP服务,下面的工作

    <bean id="WSACallbackKlen" class="nbr.ei.util.LctionCallback">
            <constructor-arg index="0" value="http://serviations.bnst.n/toezicht/ka/km/KkService/tnRequest"></constructor-arg>
            <constructor-arg index="1" value="http://servtions.bnst.n.tst.st3/toet/ka/km/Kervice"></constructor-arg>
        </bean> 
        <int:chain input-channel="kkChannel" output-channel="dest-channel">
            <ws:header-enricher>       
                <ws:soap-action value="http://servicons.belt.n/toet/ka/kk/KKserice/tnRequest"/>
            </ws:header-enricher>           
            <ws:outbound-gateway uri="http://bb-k1.ts.nst.n/wsb/router" request-callback="WSACallbackKlen" message-sender="kkMsageSender"/>
        </int:chain> 
    

    它被设置为安全的,因此在出站网关中将URI更新为 “URI=” HTTPS ://bb-k1.ts.nst.n/wsb/router“

    使用Spring上下文进行集成测试时出错-

    org.springframework.ws.client.WebServiceIOException: I/O error: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target; nested exception is javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
    at org.springframework.ws.client.core.WebServiceTemplate.sendAndReceive(WebServiceTemplate.java:561)
    at org.springframework.integration.ws.SimpleWebServiceOutboundGateway.doHandle(SimpleWebServiceOutboundGateway.java:98)
    ..
    
    Caused by: javax.net.ssl.SSLHandshakeException: 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.ssl.Alerts.getSSLException(Alerts.java:192)
        at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1964)
    

    如何为https类型创建ws:outbound gateway工作?如果需要,我不知道如何指定证书

    1 回复  |  直到 6 年前
        1
  •  1
  •   Artem Bilan    6 年前

    要在客户端处理SSL,需要使用 HttpsUrlConnectionMessageSender HttpComponentsMessageSender 并且在 cacerts 商店。

    https://www.baeldung.com/java-ssl 更多信息。

    还可以从SpringWS-Docs中借用一些信息: https://docs.spring.io/spring-ws/docs/3.0.4.RELEASE/reference/#security

    从Spring集成的角度来看,没有什么特别的事情可以做。