我有一个PFX文件。我生成了PEM和KEY文件:
openssl pkcs12 -in cert.pfx -out cert.pem -clcerts -nokeys
openssl pkcs12 -in cert.pfx -out cert.key -nocerts -nodes
我这样导入了它们:
soap.createClient( url, {wsdl_options: {
cert: fs.readFileSync('cert/certificate.pem'),
key: fs.readFileSync('cert/certificate.key')
}, wsdl_headers: {Authorization: auth}}, function(err, client) {
if(err) throw err;
client.describe();
});
但是nodemon告诉我这个错误:
Error: self signed certificate in certificate chain
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1060:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:584:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:416:38)
我想我用openssl certifacte generator做错了。
答案 0 :(得分:0)
如果您打算使用自签名证书并尝试呼叫远程资源,请尝试将rejectUnauthorized: false
添加到wsdl_options
。这有助于您测试SOAP服务,并可以替换生产中的预期证书。