【问题标题】:XML envelopped signature with Inclusivenamespace具有包容性命名空间的 XML 封装签名
【发布时间】:2022-07-25 04:01:53
【问题描述】:

使用 4D 语言编写,我必须编写低级规范化函数来检查 XML 上的签名。十几个情况下工作得很好,现在我遇到了一个新的困难:XML 包括“InclusiveNamespaces”转换。我认为这就是破坏我的签名检查算法的原因,我无法弄清楚它应该如何工作。 我最初的 XML 看起来像:

<saml2:Assertion ID="1234"
    xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
            <ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
            <ds:Reference URI="#1234">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <ec:InclusiveNamespaces PrefixList="xs"
                                                xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                    </ds:Transform>
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
                <ds:DigestValue>xxx</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
    </ds:Signature>
    <saml2:AttributeStatement xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
        <saml2:Attribute Name="myAttribute"
                        NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified">
            <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema"
                                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                                    xsi:type="xs:string">STRING</saml2:AttributeValue>
        </saml2:Attribute>
    </saml2:AttributeStatement>
</saml2:Assertion>

所以我有一个用于“xs”的“包含命名空间”,它用于 saml2:AttributeValue 的 xsi:type 属性值。我的问题是:我应该在我的规范化算法中用它做什么?使用我当前的算法,它被简单地删除,因为它没有被任何元素或属性明显使用,但我不确定它应该保存在哪里。 RFC 确实提到了这个案例,但没有足够的细节让我弄清楚...... 感谢您提供任何帮助,包括您是否拥有自己的代码,允许您规范化我的示例 XML 并返回正确的值。 :)

【问题讨论】:

    标签: xml xml-dsig


    【解决方案1】:

    使用包容性规范化,您应将所有父命名空间包含到规范化节点中,即使该命名空间未在节点本身或其子节点中使用。 详情请见specification

    【讨论】:

      猜你喜欢
      • 2013-07-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-18
      • 2023-03-07
      • 2012-08-04
      相关资源
      最近更新 更多