【问题标题】:Empty SignatureValue and DigestValue in SOAP Request using Wss4jSecurityInterceptor使用 Wss4jSecurityInterceptor 的 SOAP 请求中的空 SignatureValue 和 DigestValue
【发布时间】:2019-09-10 10:46:22
【问题描述】:

我正在更新现有 SOAP Web 服务的客户端,因为服务提供商已对其请求中的安全标头进行了一些更改。

要求是对应该存在于请求标头中的时间戳进行数字签名,并且不应对正文进行数字签名。我正在使用 XML 配置来创建我的 SOAP 请求标头并对时间戳进行数字签名。

我基本上使用 org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor 作为拦截器。问题是 Timestamp 是在请求​​标头中创建的,但是 SignatureValue 和 DigestValue 标签是空的

我已推荐https://docs.spring.io/spring-ws/site/reference/html/security.html#security-wss4j-digital-signatures

版本: Spring-ws-core --> 2.0.0.RELEASE spring-ws-security --> 2.0.0.RELEASE

  <bean id="wsClientSecurityInterceptor"    class="org.springframework.ws.soap.security.wss4j.Wss4jSecurityInterceptor">
               <property name="securementActions" value="Timestamp Signature"/>
               <property name="securementSignatureKeyIdentifier" value="DirectReference" />
               <property name="securementUsername" value="username" />
               <property name="securementPassword" value="keystorepassword" />
               <property name="securementSignatureCrypto" ref="clientCrypto"/>
               <property name="securementSignatureUser" value="username" />
               <property name="securementSignatureParts" value="{}{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp"/>
  </bean>
  <bean id="clientCrypto" class="org.springframework.ws.soap.security.wss4j.support.CryptoFactoryBean">
        <property name="keyStorePassword" value="keystorepassword" />
        <property name="keyStoreLocation" value="file:${key.store.location}"/>
        <property name="keyStoreType" value="jks" />
        <property name="keyStoreProvider" value="IBMJCE" />
</bean>

虽然时间戳被添加到标头中的 wsse:Security 元素,但属于 xmlns:ds="http://www.w3.org/2000/09/xmldsig#" 命名空间的 DigestValue 和 SignatureValue 元素是总是空的

如果我只签署正文就不会发生这种情况

我也尝试使用另一个拦截器 XwsSecurityInterceptor,但没有 Wss4jSecurityInterceptor 就无法工作,并且在与 Wss4jSecurityInterceptor 一起使用时给我相同的结果

<bean id="xwsSecurityInterceptor" class="org.springframework.ws.soap.security.xwss.XwsSecurityInterceptor">
        <property name="policyConfiguration" value="classpath:securityPolicy.xml"/>
         <property name="callbackHandlers">
            <list>
                <ref bean="keyStoreHandler"/>
            </list>
        </property>
    </bean>

     <bean id="keyStoreHandler" class="org.springframework.ws.soap.security.xwss.callback.KeyStoreCallbackHandler">
        <property name="keyStore" ref="keyStore"/>
        <property name="privateKeyPassword" value="keystorepassword"/>
    </bean>

    <bean id="keyStore" class="org.springframework.ws.soap.security.support.KeyStoreFactoryBean">
        <property name="location" value="file:${key.store.location}"/>
        <property name="password" value="keystorepassword"/>
    </bean>

【问题讨论】:

  • 我使用的是 Websphere 8.5.5
  • 在 Apache Tomcat 8.0.50 上部署了相同的应用程序,并且确实填充了签名。我现在可以将问题缩小到 WAS 8.5.5。如果有人之前遇到过这个问题,请告诉我

标签: spring spring-security spring-ws


【解决方案1】:

在参考了许多 IBM 支持帖子后,我终于找到了解决方案,并且也收到了关于实施的 QA 签收。我必须用 WAS 服务器本身上的配置替换所有用于创建 SSL 上下文的 spring mvc 配置。您可以使用脚本或手动使用 WAS 控制台来配置所有这些。

步骤:

完成此操作后,只需导航到 Services--> Service Clients,您的服务引用就会在此处可见。由于上面的第 1 点,您现在应该将上面创建的策略集和绑定附加到在 WAS 中创建的服务客户端引用。您可能必须编写脚本来附加策略集和绑定,因为在部署之后您不想执行此步骤手动

请注意:这个解决方案出现在 WAS 8.5.5.16 的版本中,spring -3.0.5.RELEASE 和 spring-ws-2.0.0.RELEASE 不支持在 SOAP 的请求负载中签名时间戳服务请求。希望这对某人有帮助!

【讨论】:

    猜你喜欢
    • 2017-05-12
    • 2021-07-25
    • 1970-01-01
    • 2011-01-10
    • 1970-01-01
    • 2017-07-29
    • 1970-01-01
    • 2022-09-30
    相关资源
    最近更新 更多