xmlsec1 签名失败 - id

xmlsec1 sign failed - id

在我的 SignInfo 节点中

<ds:Reference URI="#Id-132">...

指的是下面的节点:

<soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-132">

命令:

xmlsec1 --sign --output request-signed.xml --privkey-pem privatekey.pem raw_message.xml

我有这个错误: func=xmlSecXPathDataExecute:file=xpath.c:line=273:obj=unknown:subj=xmlXPtrEval:error=5:libxml2 库函数failed:expr=xpointer(id('Id-132'))

要使用 ids 引用进行签名是必需的 --id-attr: 参数。示例:

<ds:Reference URI="#Id-132">

<soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-132">

命令:xmlsec1 --sign --output request-signed.xml --privkey-pem privatekey.pem --id-attr:Id raw_message.xml

更多信息:https://snippets.aktagon.com/snippets/758-how-to-sign-xml-documents-using-xmldsig-xml-signature-