npm - 肥皂节点模块数字签名
问题描述
如果 npm 模块“soap”支持数字签名,请告诉我。我需要生成如下所示的肥皂标题
<s:Header>
<Action s:mustUnderstand="1"
xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://example.com
</Action>
<Signature
xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
<Reference URI="#Body">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
<DigestValue>ABCDE=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>jx5IYbz8mDxTXgV6UhhV/</SignatureValue>
<KeyInfo>
<X509Data>
<X509IssuerSerial>
<X509IssuerName>C</X509IssuerName>
<X509SerialNumber>12345</X509SerialNumber>
</X509IssuerSerial>
<X509Certificate>certificate</X509Certificate>
</X509Data>
</KeyInfo>
</Signature>
</s:Header>
解决方案
答案是肯定的。节点模块'soap'支持您的soap请求按照您的要求进行数字签名。这属于“WS-SECURITY”。您需要有一个私钥和一个公钥来执行 ws-security。
我正在提供一个示例片段,希望这会有所帮助
soap.createClient(url,async function(err,client){
if(!err){
var privateKey = 'Read your private key file (.pem file)'
var password = 'your signer password';
var wsSecurity = new soap.WSSecurityCert(privateKey['your attribute'].key, privateKey['your attribute'].cert, password, 'utf8');
client.setSecurity(wsSecurity);
client.<your_function_here>({your parameters},async function(er,result){
console.log(client.lastRequest);// This will print the request that is been called.
if(er){
console.log("API RESPONSE ERROR: "+JSON.stringify(er.message));
}else{
console.log(result);
}
})
}
})
推荐阅读
- delphi - Delphi 7中的二进制到十进制
- sql - 在字段中遇到特殊字符(例如“/”)时创建新行
- apache-spark - 如何使用 SPARK 将 JPG、PDF 文件加载到 HBASE?
- amazon-web-services - AWS RDS - 每天自动创建一个“副本”数据库
- python - Python - Numpy中线和点之间的欧几里得距离
- python - 为什么 pip --version 和 pip3 --version 在同时安装 Python3.7 时默认为 Python3.6?
- python - 如何获取 lxml.etree 的父标签属性,如“KEY”、“NAME”、Python 3.6
- selenium-webdriver - 有没有更好的方法来定位以下 HTML 代码的元素?
- button - Thymeleaf 按钮调用 url 在新选项卡中带有参数
- python - 如何在递归函数中控制函数调用的次数。即递归函数调用自身的次数