问题标签 [xml-dsig]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
xml - XML 数字签名:如何计算同文档引用 URI 的摘要值?
我的 XML 数字签名有以下摘录:
引用的 Object 元素的摘要值应该为qf9+Tj0qTkkExCEOwFz0V4aNo=。我规范化 Object 元素,并得到以下输出,这对我来说似乎是正确的:
我将它存储在文件“inputxml”中,并尝试使用以下命令获取 sha1 摘要的 base64 编码版本:
计算的摘要值与 XML 签名中的内容不匹配。我究竟做错了什么?我尝试了多种方法和调整,但无法获得正确的摘要值。
注意:XML 签名验证正确。所以值是正确的,但我缺少一些步骤或细节。谢谢你的帮助。如果不是很清楚,请告诉我如何进一步详细说明或澄清我的问题。
c# - 如何在 C# 中验证数字签名的 XML 文档?
我目前正在尝试为我的软件构建更新程序。到目前为止,这不是一项艰巨的任务,但我想对文件进行签名,以防止在这些文件被黑客入侵和修改时造成伤害(因为它会允许安装有害软件)。
我在 MSDN 和各种博客中找到了一些教程,它们完美地展示了如何签署 XML 文件。得到这个工作 - 我有一个签名附加到我的文件。
不知何故没有涉及的是:验证如何在不同的计算机上工作?我不明白我应该如何提供必要的数据来验证它。据我了解,我需要私钥来验证签名(其中包含公钥)。现在我将如何提供那个?如果我只是将它存储在应用程序中,即使加密也可以轻松抓取。
我尝试过的另一种可能的方法是嵌入 X509 证书。我什至得到了一些代码来生成这样的代码,但它总是会显示证书来自未知来源。
有什么办法不提示用户安装证书?还是完全不安装东西更好?
到目前为止,我还没有发现任何关于这件事的信息。
xml - xmlsec 无法验证签名
我正在尝试使用 xmlsec1 实用程序验证 XML(附加在问题的底部)签名。但是,在执行命令时
我得到以下堆栈跟踪:
func=xmlSecXPathDataExecute:file=xpath.c:line=273:obj=unknown:subj=xmlXPtrEval:error=5:libxml2 库函数失败:expr=xpointer(id('uuid-73c06e86-88d2-4204-91f4-3d484bc782cc' )) func=xmlSecXPathDataListExecute:file=xpath.c:line=373:obj=unknown:subj=xmlSecXPathDataExecute:error=1:xmlsec 库函数失败:func=xmlSecTransformXPathExecute:file=xpath.c:line=483:obj=xpointer :subj=xmlSecXPathDataExecute:error=1:xmlsec 库函数失败:func=xmlSecTransformDefaultPushXml:file=transforms.c:line=2411:obj=xpointer:subj=xmlSecTransformExecute:error=1:xmlsec 库函数失败:func=xmlSecTransformCtxXmlExecute:file =transforms.c:line=1242:obj=unknown:subj=xmlSecTransformPushXml:error=1:xmlsec 库函数失败:transform=xpointer func=xmlSecTransformCtxExecute:file=transforms.c:line=1302:obj=unknown:subj=xmlSecTransformCtxXmlExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigReferenceCtxProcessNode:file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file= xmldsig.c:line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec 库函数失败:node=Reference func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode: error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败 ERROR SignedInfo References (ok/ all):0/1 清单参考(ok/all):0/0 错误:无法验证文件“test.xml”```````````````error=1:xmlsec 库函数失败:func=xmlSecDSigReferenceCtxProcessNode:file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c: line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec 库函数失败:node=Reference func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1: xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败 ERROR SignedInfo References (ok/all): 0 /1 清单参考(ok/all):0/0 错误:无法验证文件“test.xml”```error=1:xmlsec 库函数失败:func=xmlSecDSigReferenceCtxProcessNode:file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c: line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec 库函数失败:node=Reference func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1: xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败 ERROR SignedInfo References (ok/all): 0 /1 清单参考(ok/all):0/0 错误:无法验证文件“test.xml”```xmlsec 库函数失败:func=xmlSecDSigReferenceCtxProcessNode:file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c:line=822: obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec library function failed:node=Reference func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec library function failed : func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec library function failed: Error: signature failed ERROR SignedInfo References (ok/all): 0/1 Manifests References (ok/all):0/0 错误:无法验证文件“test.xml”```xmlsec 库函数失败:func=xmlSecDSigReferenceCtxProcessNode:file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c:line=822: obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec library function failed:node=Reference func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec library function failed : func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec library function failed: Error: signature failed ERROR SignedInfo References (ok/all): 0/1 Manifests References (ok/all):0/0 错误:无法验证文件“test.xml”```file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c:line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error =1:xmlsec 库函数失败:node=参考 func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig。 c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败错误 SignedInfo 引用(ok/all):0/1 Manifests References(ok/all):0/0错误:无法验证文件“test.xml”```file=xmldsig.c:line=1589:obj=unknown:subj=xmlSecTransformCtxExecute:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c:line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error =1:xmlsec 库函数失败:node=参考 func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig。 c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败错误 SignedInfo 引用(ok/all):0/1 Manifests References(ok/all):0/0错误:无法验证文件“test.xml”```func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c:line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec 库函数失败:node=参考 func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=未知:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败错误 SignedInfo 引用(ok/all):0/1 清单引用(ok/all):0/0 错误:无法验证文件“test.xml”```func=xmlSecDSigCtxProcessSignedInfoNode:file=xmldsig.c:line=822:obj=unknown:subj=xmlSecDSigReferenceCtxProcessNode:error=1:xmlsec 库函数失败:node=参考 func=xmlSecDSigCtxProcessSignatureNode:file=xmldsig.c:line=563:obj=未知:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败错误 SignedInfo 引用(ok/all):0/1 清单引用(ok/all):0/0 错误:无法验证文件“test.xml”```line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败错误 SignedInfo 引用(ok/all):0/1 清单引用(ok/all):0/0 错误:无法验证文件“test.xml”```line=563:obj=unknown:subj=xmlSecDSigCtxProcessSignedInfoNode:error=1:xmlsec 库函数失败:func=xmlSecDSigCtxVerify:file=xmldsig.c:line=382:obj=unknown:subj=xmlSecDSigCtxSignatureProcessNode:error=1:xmlsec 库函数失败:错误:签名失败错误 SignedInfo 引用(ok/all):0/1 清单引用(ok/all):0/0 错误:无法验证文件“test.xml”```
根据堆栈跟踪,我认为 ID 有问题。经过一番挖掘,我发现执行
产生以下堆栈跟踪
func=xmlSecOpenSSLEvpDigestVerify:file=digests.c:line=249:obj=sha1:subj=unknown:error=12:invalid data:data 和 digest 不匹配 FAIL SignedInfo References (ok/all): 0/1 Manifests References ( ok/all):0/0 错误:无法验证文件“test.xml”
这是文件的修剪内容test.xml
:
你能解释一下我在这里做错了什么吗?如何使用 xmlsec 验证签名的 XML 文件?
java - Java xml-dsig 和命名空间的问题
我一直在尝试使用 JDK 的javax.xml.crypto.dsig
包使 XML 签名工作。
它在我没有任何命名空间时工作,但只要我添加命名空间,签名和验证就会在内存中的 DOM 对象上工作。一旦对象被转换然后再次解析,验证就会失败。
我创建了一个可以很容易看到的示例。在主方法中,在创建文档之后,我必须转换然后解析文档,在这种情况下签名和验证工作。这似乎真的很愚蠢=))
所以我的问题:有谁知道我如何修复代码,所以我不需要先将字节转换Document
为字节然后再次解析它们,以便签名验证有效?
xml - XML 关系转换算法
我正在尝试使用数字签名验证 MS Word *.docx 文件。为了进行验证,我必须计算引用节点的摘要并检查它是否与签名(sig1.xml)中给出的相同。我找不到有关如何实现关系转换以计算该摘要的信息。
签名XML部分(sig1.xml)如下:
/_rels/.rels 文件自己:
所以我需要计算/_rels/.rels的SHA1,但在计算之前我必须应用关系变换和C14N。
当我计算没有关系变换的节点摘要时(例如:)
一切都很好,只需对引用的 URI(在这种情况下为 /word/document.xml)进行 SHA1 处理,就可以得到与签名节点中给定的哈希值相同的哈希值。但是当涉及到具有关系转换的节点时 - 计算永远不会给出与签名中所述相同的值。
我的问题一般是在哪里可以找到有关这种关系转换的信息以及如何实现它?
谢谢,
乔治
.net - PowerShell 验证 SAML 签名的 XML
我们最近遇到了一个问题,即 IdP 不信任来自我们的 RP/SP 的 SAML 2.0 注销请求签名。我们正在寻找其他方法来验证 SAML 请求签名,因为 IdP 和 samltool.com 都抱怨签名验证。下面是一个示例答案,我们用来检查签名数据是否可以根据签名进行验证。
java - 实例化类的正确方法,以便我能够验证证书中的路径链
我有 3d 方库(用于 Kalkan 提供商的 sdk)。这个库的一部分检查我相信的证书路径。问题是我应该传递两个参数来正确实例化类,我可以使用我需要的其中一种方法。
这是代码:
这是构造函数的一部分:
关于任务。我已通过客户证书签署文件。我想验证客户端证书中的路径。所以我有客户的 X509Certificate 证书实例、一个中间证书和一个根证书。最后两个是磁盘上 cer 格式的文件。据我了解,我应该将所有这三个证书结合在一起。如果有人向我展示了如何创建这些cp和参数,那将非常有帮助。提前致谢。
web-services - wiremock soap ws-policy 支持?
我想知道是否有人知道wiremock 是否支持关于SOAP Web 服务的WS-Policy?
我所追求的是给wiremock一个WSDL,其中包含一些WS-Policy,其中包含响应应该是什么样子的“reciepe”。即标题中的时间戳、签名正文等。
因此,理想情况下,我只需指定肥皂主体,wiremock 将应用 WS-Policy 并添加必要的签名。
我发现这个提到 SOAP 支持的github 问题,但我从该支持中得到的印象是它只是一个任意文本响应,没有实际的 SOAP 理解/处理。
如果我愿意,是否可以插入 Apache CXF 以获得适当的 JAX-WS/WS-Policy 支持?或者将响应处理卸载到第三方库会很困难吗?
php - Create a correct PKCS7/CMS (ASN.1) from existing XML Signature in PHP
I have an XML digital signature, (xmlns="http://www.w3.org/2000/09/xmldsig
) and I want to convert this into a PKCS7 signature.
I belive I have to use an ASN.1 encoder such as https://github.com/FGrosse/PHPASN1 but I cannot understand how to create a valid pkcs7/asn.1 signaure with it.
Is this possible?