Resolving “Self Signed Certificate in Certificate Chain” Error while working in VM/VDesk

Kinjal P Darji
2 min readMay 11, 2023

Mostly in VM/VDesk there are multiple layers certificates installed in the browsers and it is common to encounter issue like below.

“error request to https://registry.npmjs.org/ failed, reason: self signed certificate in certificate chain”

There are few ways of resolving this. I will explain the one that worked for me and also other ways those can be tried out.

Resolution 1

In chrome open the site for which the certificate error is there.

Then Go to View site information. i.e. the lock icon at the start of the page and click on Connection is secure and then click on Certificate is valid. This will show the certificate chain and other certificate details.

Download the certificate by clicking on details tab and then clicking on export button.

Ensure you save the certificate as certificate chain.

Now, go to command prompt and provide the certificate to NPM as cafile using following command.

npm config set cafile "<path to your certificate file>"

Resolution 2

If above doesn’t working, then you can also set an environment variable — NODE_TLS_REJECT_UNAUTHORIZED to value 0. This will ensure the certificate failures will not affect the execution of npm install.

Resolution 3

Set strict SSL to false in NPM using below command

npm config set strict-ssl false

Resolution 4

You can also try to avoid SSL errors by using http instead of https, which can be configured using below command.

npm config set registry="http://registry.npmjs.org/"

Also sometimes, organizations have their own registry repository, so instead of using npmjs.org, you can configure the organization’s registry site.

--

--

Kinjal P Darji

Hi, I am an AEM architect and a certified AWS Developer — Associate.