SOAP请求和“错误:证书链中的自签名证书”

时间:2016-08-25 10:07:21

标签: node.js ssl soap soap-client

我有一个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做错了。

1 个答案:

答案 0 :(得分:0)

如果您打算使用自签名证书并尝试呼叫远程资源,请尝试将rejectUnauthorized: false添加到wsdl_options。这有助于您测试SOAP服务,并可以替换生产中的预期证书。