如何忽略自签名证书错误node.js soap.js

我使用soap.js在node.js中创build了一个soap客户端.Soap通信是通过https完成的。 当我尝试连接时,我不断收到此错误

{[错误:自签名证书]代码:'DEPTH_ZERO_SELF_SIGNED_CERT'}

以下是我的代码

var url = '../public/test.wsdl'; var client = soap.createClient(url,sslOptions, function(err, client) { client.setSecurity(new soap.WSSecurity('testuser', 'testpassword')); client.CheckStatus(args, function(err, result) { console.log(err); // console.log(result); }); }); 

我也尝试了以下ssl设置,但没有解决

 sslOptions = { key: fs.readFileSync( '../certs/test-key.pem'), cert: fs.readFileSync( '../certs/test-cert.pem'), rejectUnauthorized : false, secureOptions : constants.SSL_OP_NO_TLSv1_2, strictSSL : false }; 

任何帮助,将不胜感激 !!

昨天在他们的github 回购中find了它

@tesfel tesfel在2月17日发表评论

将证书添加到您的受信任列表中,或添加

 process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0" 

到你的代码。