web-services - 轴 2 和 Rampart-为什么服务返回 wsse :Security header in request?

标签 web-services soap https apache-axis rampart

我正在连接到安全服务。

我有一个 SOAP UI 项目,配置为使用 jks 文件来提供证书,以及适当的安全设置以允许我获得有效的响应。

我已经使用 AXIS 2 和 Rampart 从 JAVA 项目创建 SOAP 请求。 使用 TCPMon,我成功地获取了 SOAP 请求。

当请求在JAVA项目中运行时,我只是得到响应:

org.apache.axis2.AxisFault:请求中缺少 wsse:安全 header

但是如果我接受在 TCPMon 中捕获的相同请求并将其放入 SOAP UI 项目中,我会成功收到响应。

有人有什么想法吗?

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">  <soapenv:Header>  
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"  
soapenv:mustUnderstand="1">  
  <wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
  wsu:Id="Timestamp-1">  
    <wsu:Created>2012-06-01T15:09:12.520Z</wsu:Created>  
    <wsu:Expires>2012-06-01T15:14:12.520Z</wsu:Expires>  
  </wsu:Timestamp>  
  <wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
  EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary"  
  ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"  
  wsu:Id="CertId-ECDB0E....01">  
  MIID4DCCA0mgAwIBAgIBFjAN....</wsse:BinarySecurityToken>  
  <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"  
  Id="Signature-2">  
    <ds:SignedInfo>  
      <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />  
      <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />  
      <ds:Reference URI="#Id-15..93">  
        <ds:Transforms>  
          <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />  
        </ds:Transforms>  
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />  
        <ds:DigestValue>  
        3wgvhJ8SI2soC..IA=</ds:DigestValue>  
      </ds:Reference>  
      <ds:Reference URI="#Timestamp-1">  
        <ds:Transforms>  
          <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />  
        </ds:Transforms>  
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />  
        <ds:DigestValue>  
        VlzDT69YEl..qTlbj0=</ds:DigestValue>  
      </ds:Reference>  
    </ds:SignedInfo>  
    <ds:SignatureValue>  
    ZCRypw/..=</ds:SignatureValue>  
    <ds:KeyInfo Id="KeyId-ECD..2">  
      <wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
      wsu:Id="STRId-ECDB0E6..6193">  
        <wsse:Reference URI="#CertId-ECDB0E..01"  
        ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" />  
      </wsse:SecurityTokenReference>  
    </ds:KeyInfo>  
  </ds:Signature>  
</wsse:Security></soapenv:Header><soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-15..3"><ns2:ProductSearchV2Request xmlns:ns2="http://product.webservice.sxc.com">   
  <ns2:Strength>900</ns2:Strength>  
  <ns2:MaximumResultSetInd>true</ns2:MaximumResultSetInd>  
  <ns2:MaximumResultSet>100</ns2:MaximumResultSet>  
</ns2:ProductSearchV2Request>  


这是我正在使用的 WS-POLICY 文档:

<?xml version="1.0" encoding="UTF-8"?>  
<!--  
 !  
 ! Copyright 2006 The Apache Software Foundation.  
 !  
 ! Licensed under the Apache License, Version 2.0 (the "License");  
 ! you may not use this file except in compliance with the License.  
 ! You may obtain a copy of the License at  
 !  
 !      http://www.apache.org/licenses/LICENSE-2.0  
 !  
 ! Unless required by applicable law or agreed to in writing, software  
 ! distributed under the License is distributed on an "AS IS" BASIS,  
 ! WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
 ! See the License for the specific language governing permissions and  
 ! limitations under the License.  
 !-->  
<wsp:Policy wsu:Id="SigOnly"  
            xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"  
            xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">  
    <wsp:ExactlyOne>  
        <wsp:All>  
            <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">  
                <wsp:Policy>  
                    <sp:InitiatorToken>  
                        <wsp:Policy>  
                            <sp:X509Token  
                                    sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">  
                                <wsp:Policy>  
                                    <sp:RequireThumbprintReference/>  
                                    <sp:WssX509V3Token10/>  
                                </wsp:Policy>  
                            </sp:X509Token>  
                        </wsp:Policy>  
                    </sp:InitiatorToken>  
                    <sp:RecipientToken>  
                        <wsp:Policy>  
                            <sp:X509Token  
                                    sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">  
                                <wsp:Policy>  
                                    <sp:RequireThumbprintReference/>  
                                    <sp:WssX509V3Token10/>  
                                </wsp:Policy>  
                            </sp:X509Token>  
                        </wsp:Policy>  
                    </sp:RecipientToken>  
                    <sp:AlgorithmSuite>  
                        <wsp:Policy>  
                            <sp:TripleDesRsa15/>  
                        </wsp:Policy>  
                    </sp:AlgorithmSuite>  
                    <sp:Layout>  
                        <wsp:Policy>  
                            <sp:Strict/>  
                        </wsp:Policy>  
                    </sp:Layout>  
                    <sp:IncludeTimestamp/>  
                    <sp:OnlySignEntireHeadersAndBody/>  
                </wsp:Policy>  
            </sp:AsymmetricBinding>  
            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">  
                <wsp:Policy>  
                    <sp:MustSupportRefKeyIdentifier/>  
                    <sp:MustSupportRefIssuerSerial/>  
                </wsp:Policy>  
            </sp:Wss10>  
            <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">  
                <sp:Body/>  
            </sp:SignedParts>  
            <ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy">  
                <ramp:user>ctr</ramp:user>  
                <ramp:encryptionUser>ctr</ramp:encryptionUser>  
                <ramp:passwordCallbackClass>com.gtnet.rampart.PWCBHandler  
                </ramp:passwordCallbackClass>  

                <ramp:signatureCrypto>  
                    <ramp:crypto provider="org.apache.ws.security.components.crypto.Merlin">  
                        <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.type">JKS</ramp:property>  
                        <ramp:property name="org.apache.ws.security.crypto.merlin.file">build\resources\qa.jks</ramp:property>  
                        <ramp:property name="org.apache.ws.security.crypto.merlin.keystore.password">123123</ramp:property>  
                    </ramp:crypto>  
                </ramp:signatureCrypto>  
            </ramp:RampartConfig>  

        </wsp:All>  
    </wsp:ExactlyOne>  
</wsp:Policy>  

谢谢 艾伦

最佳答案

看起来错误不是与出站请求有关,而是与处理响应有关。 响应没有安全 header ,当我们尝试解密它时,会发生异常。

我需要以某种方式更改 Rampart 配置以仅执行出站安全,而不执行入站

我会回来报告:)


好吧,问题是一旦 Rampart 投入使用,它期望响应具有相同的安全 header 。 我解决问题的方法是删除 Rampart.mar 文件中 Inflow 安全性的处理程序。

我不确定这是否是最好的解决方案,但它对我们有用。

要删除流入处理程序: 解压 Rampart.mar 文件

注释掉 Inflow 部分

压缩 META_INF 文件夹。然后将 .zip 文件重命名为 .mar

现在,当您使用它时,因为没有为流入定义处理程序,它将仅使用标准 Axis2 响应处理程序。

我想如果您有多个使用 Rampart 的项目,其中一些在响应中具有安全 header ,而另一些则没有,您将需要不同的方法。


这里详细介绍了另一种方法。 这可能是一个更好的方法:

http://blog.rampartfaq.com/2009/11/how-to-generate-non-secure-response-to.html

异常(exception):

org.apache.axis2.AxisFault: Missing wsse:Security header in request at org.apache.rampart.handler.RampartReceiver.setFaultCodeAndThrowAxisFault(RampartReceiver.java:180) at org.apache.rampart.handler.RampartReceiver.invoke(RampartReceiver.java:99) at org.apache.axis2.engine.Phase.invoke(Phase.java:318) at org.apache.axis2.engine.AxisEngine.invoke(AxisEngine.java:251) at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:160) at org.apache.axis2.description.OutInAxisOperationClient.handleResponse(OutInAxisOperation.java:364) at org.apache.axis2.description.OutInAxisOperationClient.send(OutInAxisOperation.java:417) at org.apache.axis2.description.OutInAxisOperationClient.executeImpl(OutInAxisOperation.java:229)

关于web-services - 轴 2 和 Rampart-为什么服务返回 wsse :Security header in request?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10855451/

相关文章:

ssl - 我如何(手动)拦截自定义消息并将其返回给发出 HTTPS 请求的浏览器

php - 在 PHP 中创建单例 Web 服务的最佳方法是什么?

Java Socket Server——重定向到Web应用程序(Web服务)

从 SOAPFault 中提取错误消息时出现 java.lang.ClassCastException

SoapUI 更改端点地址

ruby - 如何从 Savon::SOAPFault 获取错误代码和描述?

c# - Web 服务传递以逗号分隔的数据

java - 如何生成 JSR-172 stub

node.js - Node js - SSL 例程 :SSL23_GET_SERVER_HELLO:unknown protocol:. 错误

c# - 请求被中止 : Could not create SSL/TLS secure channel but works from browser/POSTMAN