【问题标题】:Which bits of SOAP / WS-Security / WS-Addressing / etc do I need to send this message我需要哪些 SOAP / WS-Security / WS-Addressing / 等来发送此消息
【发布时间】:2011-03-18 08:21:51
【问题描述】:

编辑: 我认为唯一需要理解的是使用username token profile 对消息进行签名。任何关于如何实现它的指针/线索/信息都会很棒。我已经使用带有 WSE 2 的 Visual Studio .Net 2003 和用户名令牌配置文件示例这是默认的 - 所以我的后备是使用它,但更喜欢在 Linux 上运行,因为那是我们拥有的服务器。加上没有 WSE 的 Mono 端口。我的印象是,它的使用不多/已被弃用...

我必须与 Web 服务对话,并获得了下面的示例。我正在尝试将其翻译成英文……或者至少了解我需要查看哪些 WS 安全规范才能与之交流。

我正在使用 Ruby/Savon 进行其他 WS 调用,但它似乎只支持基本的 WSSE、用户名/密码。

我可以看到这条消息有一个签名 - 但它是通过外部文件/证书/代码签名的,还是我在下面有足够的详细信息可以在我自己的代码中进行相同的签名。

我没有看到任何 X509 或 Cipher 条目似乎暗示它没有使用这样的证书(在我对此的幼稚理解中),那么用于生成签名的东西可能只是消息的简单哈希?

它似乎还使用某种摘要/消息检查,因为当我尝试调整样本并重新发送它时,它被退回为无效 - 尽管我猜这可能与签名问题有关......

我不认为 Savon 支持这一点,所以我想我需要切换到 JRuby 并使用 Java WS 库,可能是 RampartAxis2 或者可能是 Spring security 位。任何提示/推荐/好的教程?我看到this from IBM,但我认为我需要更高层次的东西才能掌握“大局”

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/03/addressing"
xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">

  <soap:Header>
    <wsa:Action wsu:Id="Id-6762c167-412b-4bf8-8839-518e9bc25da5">
    http://host/path/func</wsa:Action>
    <wsa:MessageID wsu:Id="Id-00bb0af8-232d-43a8-adbb-39f230599c56">
    uuid:2005639d-39b8-4df6-bf41-e18741c45291</wsa:MessageID>
    <wsa:ReplyTo wsu:Id="Id-c53a1dbe-244f-46a9-b656-883f4b06dcfe">
      <wsa:Address>
      http://schemas.xmlsoap.org/ws/2004/03/addressing/role/anonymous</wsa:Address>
    </wsa:ReplyTo>
    <wsa:To wsu:Id="Id-017877f6-e5a3-43ae-aa2b-4886adb7060c">
    http://host/path/func.asmx</wsa:To>
    <wsse:Security soap:mustUnderstand="1">
      <wsu:Timestamp wsu:Id="Timestamp-1a38d0f9-077f-4e95-991b-fa899a171920">

        <wsu:Created>2011-03-14T15:00:09Z</wsu:Created>
        <wsu:Expires>2011-03-14T15:05:09Z</wsu:Expires>
      </wsu:Timestamp>
      <wsse:UsernameToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
      wsu:Id="SecurityToken-42ae32d2-f6ff-431e-9369-7696b44965e3">
        <wsse:Username>crypteduser</wsse:Username>
        <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">
        cryptedpass</wsse:Password>
        <wsse:Nonce>fLSoqLm9kuOumxy39JRHaw==</wsse:Nonce>
        <wsu:Created>2011-03-14T15:00:09Z</wsu:Created>
      </wsse:UsernameToken>
      <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
        <SignedInfo>
          <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"
          xmlns:ds="http://www.w3.org/2000/09/xmldsig#" />
          <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#hmac-sha1" />
          <Reference URI="#Id-6762c167-412b-4bf8-8839-518e9bc25da5">

            <Transforms>
              <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>SAYl5o1kh33HteOe0L7G6KIKqWg=</DigestValue>
          </Reference>
          <Reference URI="#Id-00bb0af8-232d-43a8-adbb-39f230599c56">

            <Transforms>
              <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>//LMuFkNC1FO1/9A9W7l6o75Y2M=</DigestValue>
          </Reference>
          <Reference URI="#Id-c53a1dbe-244f-46a9-b656-883f4b06dcfe">

            <Transforms>
              <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>9pgN7bU48UKi1UTnpOCikOnp2G0=</DigestValue>
          </Reference>
          <Reference URI="#Id-017877f6-e5a3-43ae-aa2b-4886adb7060c">

            <Transforms>
              <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>lWZNjtSHfVtiZeOFZAosV868Uos=</DigestValue>
          </Reference>
          <Reference URI="#Timestamp-1a38d0f9-077f-4e95-991b-fa899a171920">

            <Transforms>
              <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>H3nYPY6kfIWEIWQhpwaz8VKeQIM=</DigestValue>
          </Reference>
          <Reference URI="#Id-f95dfea2-3af8-4e95-8e60-141858db9532">

            <Transforms>
              <Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>uRTu+Hzxw+zdaTYgW0z+j35diIQ=</DigestValue>
          </Reference>
        </SignedInfo>
        <SignatureValue>
        Hdn2wxWhmr450pefMuc41o6GgOA=</SignatureValue>
        <KeyInfo>
          <wsse:SecurityTokenReference>
            <wsse:Reference URI="#SecurityToken-42ae32d2-f6ff-431e-9369-7696b44965e3"
            ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#UsernameToken" />
          </wsse:SecurityTokenReference>
        </KeyInfo>
      </Signature>
    </wsse:Security>
  </soap:Header>
  <soap:Body wsu:Id="Id-f95dfea2-3af8-4e95-8e60-141858db9532">
    <func xmlns="http://host/path/">
      <xml_in>yucky xml inside xml...</xml_in>
    </func>
  </soap:Body>
</soap:Envelope>

非常感谢您提供的任何提示/指示。

问候, 克里斯

编辑

似乎类似于这个问题......它确实使用了 X509 证书,所以可能需要它。 目前正在为此阅读wikipedia entry

EDIT2

看起来像这样 - 希望是基于用户名的选项...http://msdn.microsoft.com/en-us/library/ms824647.aspx

EDIT3

我想我拥有大部分 sorted now - 最重要的是用户名摘要。怎么办——签名值从何而来……

EDIT4

认为我最好的选择是在 .Net 中编写一个客户端,或者这会给我足够的线索直接在 Ruby 中完成,或者我可以将它包装成一个更简单的版本 - 至少在短期内......

【问题讨论】:

  • 欢迎来到痛苦的世界;让 OSS SOAP 实现与 MS 很好地配合并不像应有的那么容易。查看 WSO2,它们支持这种 Java/MS SOAP 互操作...
  • 想我可能不得不走那条路 - 但这似乎也相当安静/不受支持:(
  • 您是否尝试过简单地使用“添加服务引用”来指向 WSDL?发生了什么?
  • 从 Java 中,我得到无效的用户名令牌。目前正在尝试使用哪个版本的 VS 来处理链接代码 - 我猜它的 VS 2003 带有 WSE 扩展...

标签: c# .net visual-studio web-services ws-security


【解决方案1】:

这并不是一个完整的答案,只是我注意到的几件事。

wsse:SecurityTokenReference 指的是这个文档(以一种神秘的肥皂方式):http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0.pdf

我会通读:3.2 令牌参考

另外,父部分提到了这个公式:

Password_Digest = Base64 ( SHA-1 ( nonce + created + password ) )  

也许可以试试这样的签名?

Password_Digest = Base64 ( SHA-1 ( nonce + created + UsernameToken ) )  

【讨论】:

  • 谢谢,虽然我认为这与密码文本本身的摘要有关 - Savon 现在处理了。我希望使用用户名/密码位来消化部分更广泛的消息,就像您使用证书所做的那样。
猜你喜欢
  • 2011-04-26
  • 1970-01-01
  • 1970-01-01
  • 2013-12-22
  • 2010-10-16
  • 2021-08-19
  • 2015-03-14
  • 2017-08-14
  • 2010-10-11
相关资源
最近更新 更多