问题描述
我正在使用一个外部api,这需要我为双向tls身份验证创建一个saml断言。我正在构建的用于与api通信的客户端是用nodejs编写的。我找不到任何可以为我创建saml断言的库,所以我最终尝试了从xml文件导入的saml断言,并使用把手填充了必填字段。我现在唯一缺少的是签名,我很难找到有关生成的文档。
这是我要完成的工作的一个示例:
<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>
在前面的示例中,我需要用于签名和摘要的值,对于如何生成这些值的任何见解都将受到赞赏。动态地(以编程方式)生成它们的能力将是理想的。我们正在使用自签名的X509证书。预先感谢!
解决方法
我发现了xml-crypto库,它似乎可以满足我的需求。