【问题标题】:Separate Keystore for Spring-WS SSL handshake and Message Encryption用于 Spring-WS SSL 握手和消息加密的单独密钥库
【发布时间】:2015-04-20 02:50:43
【问题描述】:

我有一个关于 SSLHandshakeException talking to a https Web service using Spring WebServiceTemplate

博罗达克回答

“无需将密钥导入密钥库。”

如果我们不提供密钥库,那么 Httpclient 将使用什么来发送 SSL 握手的客户端证书?

我需要调用业务伙伴的 Web 服务 -

a) 使用公钥证书 X 使用 SSL 进行身份验证

b) 使用公钥证书对 SOAP 消息进行加密和签名 Y

我想我需要将证书 Y 指定为以下内容:

<bean class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
    <property name="securementActions" value="Signature"/>
    <property name="securementSignatureKeyIdentifier" value="DirectReference"/>
    <property name="securementUsername" value="mycert"/>
    <property name="securementPassword" value="certpass"/>
    <property name="securementSignatureCrypto">
      <bean class="org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean">
        <property name="keyStorePassword" value="123456"/>
        <property name="keyStoreLocation" value="classpath:/keystore.jks"/>
      </bean>
    </property>
</bean>

我不确定如何/在何处为 SSL 握手指定证书 X。我认为它是 HttpClient,但我没有在 borodark 发布的 XML 中看到它。

请帮忙!

【问题讨论】:

    标签: ssl spring-ws webservicetemplate


    【解决方案1】:

    在您配置密钥库的 xml 文件中,您应该有如下内容:

                <beans>
                   <bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
                   <property name="keyStore" ref="keyStore"/>
                   <property name="privateKeyPassword" value="changeit"/>
               </bean>
    
               <bean id="keyStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
                   <property name="location" value="classpath:keystore.jks"/>
                   <property name="password" value="changeit"/>
               </bean>
           </beans>
    

    这里的提示是

         <property name="location" value="classpath:keystore.jks"/>
    

    那是密钥库的路径.. 现在,您可能可以在密钥库中使用某个别名来进行 ssl 握手(这就是您在此处配置的内容),此外,安全策略利用同一个文件,但随后又在安全策略文件,您可以指定不同的别名.. 这应该可以解决问题.. 考虑一下,而

        <property name="location" value="classpath:keystore.jks"/>
    

    表示您可以使用其他形式来引用战争本身之外的资源的类路径,这样您就可以在完全不接触战争的情况下更改证书..

    【讨论】:

      猜你喜欢
      • 2016-02-13
      • 2012-09-19
      • 1970-01-01
      • 1970-01-01
      • 2022-01-28
      • 2011-12-06
      • 2015-10-07
      • 1970-01-01
      • 2011-08-18
      相关资源
      最近更新 更多