Node.js – Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID

apacheexpressnode.jssocket.iossl

I am implementing node js script over https.

Node js

const options = {
  key: fs.readFileSync('private.key'),
  cert: fs.readFileSync('cert.crt'),    
  // This is necessary only if using the client certificate authentication.
  requestCert: true,
  rejectUnauthorized: true,

  // This is necessary only if the client uses the self-signed certificate.
  ca: [fs.readFileSync('client-cert.pem')]
};

On each request this is giving error:- ERR_CERT_AUTHORITY_INVALID

I have searched a lot but nothing found.

I use below command for generating client key:-

openssl req -x509 -newkey rsa:2048 -keyout client-key.pem -out
client-cert.pem -days 365

I create .crt and private keys on server and using them.

What I am doing wrong here?

Best Answer

--Firstly, Right-click on your computer’s time, then select the option that says "Adjust date/time". --"Sync now" under "Synchronize your clock", and click on it. so, your system syncing your computer clock. look at : https://kinsta.com/knowledgebase/neterr-cert-authority-invalid/

Related Topic