在Node.js Soap中为客户端和wsdl设置基本授权

时间:2019-04-26 16:29:31

标签: web-services authentication soap basic-authentication node-soap

My soap service requires basic authentication which I have provided. But still showing error about some certification. Is the client.setSecurity not working or is there any other issue with the code ?

url = 'Mywsdlfile.wsdl';
const auth = "Basic " + new Buffer.from(username + ":" + password).toString("base64");

soap.createClient(url, { wsdl_headers: {Authorization: auth} }, function (err, client) {
   if (err) {
                console.log('Error unable to create client');
            }
client.setSecurity(new soap.BasicAuthSecurity(username, password));

client.myservicefromwsdl(args, function (err, result) {
    if (err) {
                    console.log('Error unable to call my service');
                }
                else {
                    console.log('Result: ', result);
                }
})

I am getting error:
Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Host: somedoain.com. is not in the cert's altnames: DNS:somedomain.com
    at Object.checkServerIdentity (tls.js:228:17)
    at TLSSocket.onConnectSecure (_tls_wrap.js:1059:27)
    at TLSSocket.emit (events.js:182:13)
    at TLSSocket._finishInit (_tls_wrap.js:631:8)

----------
----------

由于这是基本授权,因此它不需要任何认证。还是为什么我会遇到与认证有关的问题?

我也尝试将其添加到客户端: process.env [“ NODE_TLS_REJECT_UNAUTHORIZED”] = 0;

但是在这种情况下,结果生成并且为空{}

0 个答案:

没有答案