question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hostname/IP doesn't match certificate's altnames even with agentOptions.servername set

See original GitHub issue

axios version: 0.18.0 node version: 8.11.2

I’m getting the following this exception:

Hostname/IP doesn't match certificate's altnames: "Host: localhost. is not in the cert's altnames: DNS:localhost.company.com"

When trying to make the following request:

axios({
	method: 'get',
	url: `https://localhost:${API_PORT}`,
	agentOptions: new https.Agent({
		pfx: clientCert,
		passphrase: password,
		ca: ca,
		servername: 'localhost.company.com'
	})
});

The altname for the certificate was signed as “localhost.company.com”. When I make the same request w/ request-promise it works, it seems the ‘servername’ field doesnt get honor.

request({
	method: 'GET',
	uri: `https://localhost:${API_PORT}`,
	agentOptions: {
		pfx: clientCert,
		passphrase: password,
		ca: ca,
		servername: 'localhost.company.com'
	}
})
``



Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7

github_iconTop GitHub Comments

10reactions
frangeriscommented, Aug 3, 2018

@b4dnewz If you’re using nodejs put this before make the request:

process.env.NODE_TLS_REJECT_UNAUTHORIZED = false

Axios also support it…

// At instance level
const instance = axios.create({
  httpsAgent: new https.Agent({  
    rejectUnauthorized: false
  })
});
instance.get('https://something.com/foo');

// At request level
const agent = new https.Agent({  
  rejectUnauthorized: false
});
axios.get('https://something.com/foo', { httpsAgent: agent });
4reactions
iamakshatjaincommented, Jul 25, 2019

Hey can anyone let me know why does that actually happens. Would be really helpful. Thanks in advance.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Hostname/IP doesn't match certificate's altnames
Generally speaking, it's a good idea to use the stable versions of node (even version numbers, 0.6.x, 0.8.x) for non-development code. The ...
Read more >
Hostname/IP does not match certificate's altnames: Host
I am trying to upload files to linode object storage using nodejs & aws-sdk but getting following error: ``` NetworkingError [ERR_TLS_CERT_ALTNAME_INVALID]: ...
Read more >
Solved: Getting the Error: Hostname/IP doesn't match certi...
The "Error:Hostname/IP doesn't match certificate's altnames" ... With the servername, I was able to get the server certificate information.
Read more >
Hostname/IP does not match certificate's alternates - General
Hello everyone ! I have installed Node Red on Synology NAS using Docker. I have also imported these nodes I am experiencing an...
Read more >
Hostname/IP doesn't match certificate's altnames | Node & Nginx
And why does he accidentally switch to the ampinbaunatal.de domain? Nginx config for both servers: server { server_name oauth2.healform.de; ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found