4

我尝试使用以下命令使用 P12 私钥签署我的测试 xml,并收到以下错误:

xmlsec1 --sign --output tested.payload.xml --pkcs12 SenderCert/sender.p12 --pwd password tested.xml 

Error: failed to find default node with name="Signature"
Error: failed to load template "tested.xml"
Error: failed to sign file "tested.xml"

有什么建议吗?

4

2 回答 2

2

Security您的标签内应该有一个标签Header,在您的 SOAP 消息中具有大致这样的结构:

<soapenv:Header>
<wsse:Security soapenv:mustUnderstand="1" 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">
    <wsse:BinarySecurityToken EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="X509-A64424329E443DAEFE14265088735561">CERTIFICATE_HERE</wsse:BinarySecurityToken>
    <ds:Signature Id="SIG-A64424329E443DAEFE14265088736534" xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                <ec:InclusiveNamespaces PrefixList="raad soapenv" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
            </ds:CanonicalizationMethod>
            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
            <ds:Reference URI="#id-15652DE155DD8DFF971422029213153243">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
                        <ec:InclusiveNamespaces PrefixList="raad" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/>
                    </ds:Transform>
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
                <ds:DigestValue/>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue/>
        <ds:KeyInfo Id="KI-A64424329E443DAEFE14265088736252">
            <wsse:SecurityTokenReference wsu:Id="STR-A64424329E443DAEFE14265088736273">
                <wsse:Reference URI="#X509-A64424329E443DAEFE14265088735561" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/>
            </wsse:SecurityTokenReference>
        </ds:KeyInfo>
    </ds:Signature>
</wsse:Security>
</soapenv:Header>

xmlsec1 不插入新标签,而是用值填充必要的标签

于 2015-03-16T13:26:54.797 回答
0

我刚刚遇到了同样的问题。我通过添加<samlsig:Signature>标签来解决它,这是OASIS中的标准SAML,然后就可以了。

但问题是我需要简化<samlp:AuthnRequest>以调整与 SAML 标准不是 100% 相同的 IDP。我不知道如何解决这种情况。有人知道吗?

于 2017-12-05T03:41:30.150 回答