nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.44k stars 276 forks source link

Error: unable to verify the first certificate #4375

Closed liteCarma closed 2 months ago

liteCarma commented 2 months ago

Details

Today, on two of my computers (Windows 11), I ran into a problem validating certificates for almost any site. I found only one site that doesn't cause this error and that is www.bing.com. I have also tried running the same request through curl and openssl, with which there is no certificate validation problem.

const https = require('node:https');
// work only with www.bing.com
https.get('https://www.google.com/', (res) => {
  res.setEncoding('utf8');
  res.on('data', console.log);

}).on('error', (e) => {
  console.error(e);
});

/*Error: unable to verify the first certificate
    at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
    at TLSSocket.emit (node:events:518:28)
    at TLSSocket._finishInit (node:_tls_wrap:1085:8)
    at ssl.onhandshakedone (node:_tls_wrap:871:12) {
  code: 'UNABLE_TO_VERIFY_LEAF_SIGNATURE'
  */

Node.js version

Not applicable.

Example code

20.12.2

Operating system

Windows 11

Scope

runtime

Module and version

node:https

liteCarma commented 2 months ago

The problem is related to ESET(Nod32) antivirus. After uninstalling it the problem disappeared, but after reinstalling it came back. I don't know what happened as it worked for me for a long time before without any problems.

askaribragimov commented 2 months ago

https://forum.eset.com/topic/40702-eset-ssl-protection-produces-an-invalid-certificate-chain-for-nodejs-apps