我使用soap.js在node.js中创建了一个soap客户端。通过https进行Soap通信。当我尝试连接时,我不断收到此错误
{[错误:自签名证书]代码:'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
};
任何帮助都将不胜感激!!
答案 0 :(得分:25)
Found it yesterday on their github repo
@tesfel tesfel commented on 17 Feb
Add the cert to your trusted list at you computer or add
process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"
to your code.