0
votes

I am working with an external api that requires me to create a saml assertion for mutual tls authentication. The client I am building to communicate with the api is written in nodejs. I was unable to find any libraries that would handle creating saml assertions for me so I ended up templating a saml assertion imported from an xml file and populated the necessary fields using handlebars. The only thing I am missing now is the signature, which I am having a hard time finding documentation on generating.

Here is an example of what I am trying to complete:

<ds:Signature>
    <ds:SignedInfo>
        <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
        <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
        <ds:Reference URI="#_df0cbca2-3511-4586-b5f3-0211b1700413">
            <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#"/>
            </ds:Transforms>
            <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
            <ds:DigestValue>{{fillMeIn}}</ds:DigestValue>
        </ds:Reference>
    </ds:SignedInfo>
    <ds:SignatureValue>{{MeToo!}}</ds:SignatureValue>
    <ds:KeyInfo>
        <ds:X509Data>
            <ds:X509Certificate>...secret...certificate...</ds:X509Certificate>
        </ds:X509Data>
    </ds:KeyInfo>
</ds:Signature>

In the previous example I need values for the signature and digest, Any insight into how to generate these values would be appreciated. The ability to generate them dynamically (programatically) would be ideal. We are using self signed X509 certificates. Thanks in advance!

1

1 Answers

0
votes

I found the xml-crypto library, which seems like it does what I am looking for.