【发布时间】:2020-12-30 02:58:02
【问题描述】:
我正在使用一个外部 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 证书。提前致谢!
【问题讨论】:
标签: node.js hash saml digital-signature x509certificate