Npm SELF_SIGNED_CERT_IN_CHAIN on Azure

2020-02-05 12:36发布

问题:

Since npm dropped support for self signed certs yesterday, I can no longer install any packages from npm running on Windows Azure.

On my local machine I could solve the issue by applying this official fix. However, I couldn't find a way to fix the problem on my site instance. Any ideas?

回答1:

Until we update NPM on Azure, one simple way to work around this is to create a custom deployment script (info here).

Here is a sample repo that demonstrates what to customize: https://github.com/davidebbo-test/AzureNpmCertWorkaround. Specifically, look at this commit, which uses the npm config set ca "" workaround.

If you don't want to deal with generating a custom deployment script using the Azure tool, you can simply grab the .deployment and the deploy.cmd from the test repo, and commit them to the root of your repo.



回答2:

Since yesterday (Feb 27, 2014) NPM doesn't support self signed certificates anymore: http://blog.npmjs.org/post/78085451721/npms-self-signed-certificate-is-no-more

The solution: either

Upgrade your version of npm

npm update -g

-- or --

Tell your current version of npm to use known registrars

npm config set ca=""

-- or ---

As last resort resolution I don't suggest this for security issues, using SSL is always safer, switch your registry to use HTTP instead of HTTPS:

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



回答3:

You can't run npm install npm -g. npm install being broken is the problem, remember? A good tip from the comments on npm's blog post, worked like a charm:

npm config set strict-ssl false

npm install npm -g

npm config set strict-ssl true

You may need to use sudo.



回答4:

Error Name: Error: SELF_SIGNED_CERT_IN_CHAIN

Steps to be followed to overcome this error:

1) Update Node.js and npm to its latest version,

2) Run these three commands in a sequence.

  -npm config set strict-ssl false
  -npm update npm –g
  -npm config set strict-ssl true

3) Set properties proxy and https-proxy in the npm config using these commands:

  -npm config set proxy “http://<proxy-name>:8080” 
  -npm config set https-proxy “http://<proxy-name>:8080”