How to fix 'Hostname/IP does not match certificate's altnames'

Viewed 9629

I have a problem when I run get a response for service. There are two services. For the first service, it's working perfectly but in the second I have issue "Error [ERR_TLS_CERT_ALTNAME_INVALID]: Hostname/IP does not match certificate's altnames: Cert is empty". When I used Postman with certificates its works perfectly. What should I set or implement to make it works?​

I tried using: checkServerIdentity, rejectUnauthorized: true.

let options = {
    hostname: 'ws.aaa.bbb.nn',
    path: '/api',
    method: 'GET',
    key: fs.readFileSync('/private.crt'),
    cert: fs.readFileSync('/public.crt'),
    passphrase: '***'
};

const req = https.request(options, (res) => {
    let body = '';
    res.on('data', (chunk)=> {
        body += chunk;
        console.log(body)
    });
});

Should be status code 200.

2 Answers

Seems you got a bad certificate. Get a correct one or just turn the SSL certificate verification off.

I had the same problem, Just try to set Authorization Type to "Inherit auth from parent".

Related