包络签名到底有什么变化?

mik*_*ikl 2 xml digital-signature

如果我想用envoloped签名签署下一个XML代码:

<root>
<element>
<child>text node</child>
</element>
</root>
Run Code Online (Sandbox Code Playgroud)

然后,签名XML代码在签名的XML代码中进行,方式如下所示:

<root>
<element>
<child>text node</child>
</element><Signature xmlns="http://www.w3.org/2000/09/xmldsig#">...</Signature>
</root>

Notice: no line break nor single character is added outside Signature element since that would invalidate the signature.
Run Code Online (Sandbox Code Playgroud)

XML包含的签名代码包括<Transform Algorithm>,其指定代码必须遭受的修改,严格地说,无论是在签名还是验证过程中都进行.<Transform Algorithm>是下一个:

<Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
Run Code Online (Sandbox Code Playgroud)

在W3C网站(官方文档)中,将上面的表达式与下面的表达式进行比较.在这两种情况下都必须产生相同的输出.

<XPath xmlns:dsig="&dsig;">
   count(ancestor-or-self::dsig:Signature |
   here()/ancestor::dsig:Signature[1]) >
   count(ancestor-or-self::dsig:Signature)</XPath>
Run Code Online (Sandbox Code Playgroud)

参考:http://www.w3.org/TR/xmldsig-core/#sec-EnvelopedSignature

变形之前:

案例1(签署):

<root>
<element>
<child>text node</child>
</element>
</root>
Run Code Online (Sandbox Code Playgroud)

案例2(签字):

<root>
<element>
<child>text node</child>
</element><Signature xmlns="http://www.w3.org/2000/09/xmldsig#">...</Signature>
</root>
Run Code Online (Sandbox Code Playgroud)

变换后:

<root>
<element>
<child>text node</child>
</element>
</root>
Run Code Online (Sandbox Code Playgroud)

在这两种情况下都会生成相同的输出,这使我们可以验证签名数据是否可信.

我仍然遇到服务器问题,说我的签名无效,有人可以确认我是否正确地进行了转换?

非常感谢

问候

mik*_*ikl 6

Transform的确切功能是用它的后代擦除整个Signature元素.一个实际的例子是下一个签名数据:

<root>
  <element>
    <child>text node</child>
  </element>
  <Signature xmlns="http://www.w3.org/2000/09/xmldsig#">...</Signature>
</root>
Run Code Online (Sandbox Code Playgroud)

Transform必须产生下一个输出:

<root>
  <element>
    <child>text node</child>
  </element>

</root>
Run Code Online (Sandbox Code Playgroud)

请注意Signature之外的每个字符都会被保留,包括每个换行符和空格键.如果我们用冒号表示空格键,我们有下一个视图:

<root>
::<element>
::::<child>text node</child>
::</element>
::
</root>
Run Code Online (Sandbox Code Playgroud)

我建议访问下一个链接,我可以从中清除对该问题的所有怀疑:http: //www.di-mgt.com.au/xmldsig2.html

最好的链接是它包含一个真实的签名示例,任何人都可以从中重现相同的DigestValue并确认文档(实际部分在学习过程中非常重要).