Self signed certificate in certificate chain ошибка

Option 1: Disable the warning (useful for dev)

From your question I’m guessing you are doing this in development as you are using a self signed certificate for SSL communication.

If that’s the case, add as an environment variable wherever you are running node

export NODE_TLS_REJECT_UNAUTHORIZED='0'
node app.js

or running node directly with

NODE_TLS_REJECT_UNAUTHORIZED='0' node app.js

This instructs Node to allow untrusted certificates (untrusted = not verified by a certificate authority)

If you don’t want to set an environment variable or need to do this for multiple applications npm has a strict-ssl config you set to false

npm config set strict-ssl=false

Option 2: Load in CA cert, like postman (useful for testing with TLS)

If you have a CA cert already like the poster @kDoyle mentioned then you can configure in each request (thanks @nic ferrier).

 let opts = {
    method: 'GET',
    hostname: "localhost",
    port: listener.address().port,
    path: '/',
    ca: fs.readFileSync("cacert.pem")
  };

  https.request(opts, (response) => { }).end();

Option 3: Use a proper SSL Cert from a trusted source (useful for production)

letsencrypt.org is free, easy to set up and the keys can be automatically rotated. https://letsencrypt.org/docs/

My .npmrc looks like this:

registry=http://registry.npmjs.org/
strict-ssl=false
python=python2.7
ca=

It shouldn’t even try to open a SSL connection because I’m using HTTP for the registry.

npm install protractor gives an error when running node-gyp «Error: self signed certificate in certificate chain»:

> utf-8-validate@1.1.0 install .node_modulesprotractornode_modulesselenium-webd
rivernode_moduleswsnode_modulesutf-8-validate
> node-gyp rebuild


.node_modulesprotractornode_modulesselenium-webdrivernode_moduleswsnode_modu
lesutf-8-validate>if not defined npm_config_node_gyp (node "C:Program Filesiojsnode_modulesnpmbinnode-gyp-bin\..
..node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1010:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:566:8)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp
\bin\node-gyp.js" "rebuild"
gyp ERR! cwd .node_modulesprotractornode_modulesselenium-webdrivernode_modules
wsnode_modulesutf-8-validate
gyp ERR! node -v v3.0.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

> bufferutil@1.1.0 install .node_modulesprotractornode_modulesselenium-webdrive
rnode_moduleswsnode_modulesbufferutil
> node-gyp rebuild


.node_modulesprotractornode_modulesselenium-webdrivernode_moduleswsnode_modu
lesbufferutil>if not defined npm_config_node_gyp (node "C:Program Filesiojsnode_modulesnpmbinnode-gyp-bin\....
node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1010:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:566:8)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp
\bin\node-gyp.js" "rebuild"
gyp ERR! cwd .node_modulesprotractornode_modulesselenium-webdrivernode_modules
wsnode_modulesbufferutil
gyp ERR! node -v v3.0.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.1.0
npm WARN optional dep failed, continuing bufferutil@1.1.0
protractor@2.1.0 node_modulesprotractor
├── jasminewd@1.1.0
├── jasminewd2@0.0.5
├── html-entities@1.1.3
├── saucelabs@0.1.1
├── q@1.0.0
├── minijasminenode@1.1.1
├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
├── adm-zip@0.4.4
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── jasmine@2.3.1 (exit@0.1.2, jasmine-core@2.3.4)
├── source-map-support@0.2.10 (source-map@0.1.32)
├── accessibility-developer-tools@2.6.0
├── request@2.36.0 (qs@0.6.6, forever-agent@0.5.2, aws-sign2@0.5.0, oauth-sign@0.3.0, tunnel-agent@0.4.1, json-stringify
-safe@5.0.1, mime@1.2.11, node-uuid@1.4.3, form-data@0.1.4, http-signature@0.10.1, tough-cookie@2.0.0, hawk@1.0.0)
├── lodash@2.4.2
└── selenium-webdriver@2.45.1 (tmp@0.0.24, rimraf@2.4.2, xml2js@0.4.4, ws@0.7.2)
. > npm install protractor
-


> bufferutil@1.1.0 install .node_modulesprotractornode_modulesselenium-webdrive
rnode_moduleswsnode_modulesbufferutil
> node-gyp rebuild


.node_modulesprotractornode_modulesselenium-webdrivernode_moduleswsnode_modu
lesbufferutil>if not defined npm_config_node_gyp (node "C:Program Filesiojsnode_modulesnpmbinnode-gyp-bin\....
node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1010:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:566:8)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp
\bin\node-gyp.js" "rebuild"
gyp ERR! cwd .node_modulesprotractornode_modulesselenium-webdrivernode_modules
wsnode_modulesbufferutil
gyp ERR! node -v v3.0.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

> utf-8-validate@1.1.0 install .node_modulesprotractornode_modulesselenium-webd
rivernode_moduleswsnode_modulesutf-8-validate
> node-gyp rebuild


.node_modulesprotractornode_modulesselenium-webdrivernode_moduleswsnode_modu
lesutf-8-validate>if not defined npm_config_node_gyp (node "C:Program Filesiojsnode_modulesnpmbinnode-gyp-bin\..
..node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1010:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:566:8)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp
\bin\node-gyp.js" "rebuild"
gyp ERR! cwd .node_modulesprotractornode_modulesselenium-webdrivernode_modules
wsnode_modulesutf-8-validate
gyp ERR! node -v v3.0.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN optional dep failed, continuing bufferutil@1.1.0
npm WARN optional dep failed, continuing utf-8-validate@1.1.0
protractor@2.1.0 node_modulesprotractor
├── jasminewd@1.1.0
├── jasminewd2@0.0.5
├── html-entities@1.1.3
├── saucelabs@0.1.1
├── q@1.0.0
├── minijasminenode@1.1.1
├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
├── adm-zip@0.4.4
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── jasmine@2.3.1 (exit@0.1.2, jasmine-core@2.3.4)
├── accessibility-developer-tools@2.6.0
├── source-map-support@0.2.10 (source-map@0.1.32)
├── lodash@2.4.2
├── request@2.36.0 (forever-agent@0.5.2, aws-sign2@0.5.0, qs@0.6.6, oauth-sign@0.3.0, tunnel-agent@0.4.1, json-stringify
-safe@5.0.1, mime@1.2.11, node-uuid@1.4.3, form-data@0.1.4, http-signature@0.10.1, tough-cookie@2.0.0, hawk@1.0.0)
└── selenium-webdriver@2.45.1 (tmp@0.0.24, rimraf@2.4.2, xml2js@0.4.4, ws@0.7.2)
. > npm install protractornpm config set ca ""
. > npm config set ca ""
. > npm install protractor
|
> utf-8-validate@1.1.0 install .node_modulesprotractornode_modulesselenium-webd
rivernode_moduleswsnode_modulesutf-8-validate
> node-gyp rebuild


.node_modulesprotractornode_modulesselenium-webdrivernode_moduleswsnode_modu
lesutf-8-validate>if not defined npm_config_node_gyp (node "C:Program Filesiojsnode_modulesnpmbinnode-gyp-bin\..
..node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1010:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:566:8)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp
\bin\node-gyp.js" "rebuild"
gyp ERR! cwd .node_modulesprotractornode_modulesselenium-webdrivernode_modules
wsnode_modulesutf-8-validate
gyp ERR! node -v v3.0.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok

> bufferutil@1.1.0 install .node_modulesprotractornode_modulesselenium-webdrive
rnode_moduleswsnode_modulesbufferutil
> node-gyp rebuild


.node_modulesprotractornode_modulesselenium-webdrivernode_moduleswsnode_modu
lesbufferutil>if not defined npm_config_node_gyp (node "C:Program Filesiojsnode_modulesnpmbinnode-gyp-bin\....
node_modulesnode-gypbinnode-gyp.js" rebuild )  else (node  rebuild )
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1010:38)
gyp ERR! stack     at emitNone (events.js:67:13)
gyp ERR! stack     at TLSSocket.emit (events.js:166:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:566:8)
gyp ERR! System Windows_NT 6.3.9600
gyp ERR! command "C:\Program Files\iojs\node.exe" "C:\Program Files\iojs\node_modules\npm\node_modules\node-gyp
\bin\node-gyp.js" "rebuild"
gyp ERR! cwd .node_modulesprotractornode_modulesselenium-webdrivernode_modules
wsnode_modulesbufferutil
gyp ERR! node -v v3.0.0
gyp ERR! node-gyp -v v2.0.2
gyp ERR! not ok
npm WARN optional dep failed, continuing utf-8-validate@1.1.0
npm WARN optional dep failed, continuing bufferutil@1.1.0
protractor@2.1.0 node_modulesprotractor
├── jasminewd@1.1.0
├── jasminewd2@0.0.5
├── saucelabs@0.1.1
├── html-entities@1.1.3
├── q@1.0.0
├── minijasminenode@1.1.1
├── optimist@0.6.1 (wordwrap@0.0.3, minimist@0.0.10)
├── adm-zip@0.4.4
├── jasmine@2.3.1 (exit@0.1.2, jasmine-core@2.3.4)
├── source-map-support@0.2.10 (source-map@0.1.32)
├── accessibility-developer-tools@2.6.0
├── lodash@2.4.2
├── glob@3.2.11 (inherits@2.0.1, minimatch@0.3.0)
├── request@2.36.0 (aws-sign2@0.5.0, qs@0.6.6, forever-agent@0.5.2, oauth-sign@0.3.0, tunnel-agent@0.4.1, json-stringify
-safe@5.0.1, mime@1.2.11, node-uuid@1.4.3, form-data@0.1.4, http-signature@0.10.1, tough-cookie@2.0.0, hawk@1.0.0)
└── selenium-webdriver@2.45.1 (tmp@0.0.24, rimraf@2.4.2, xml2js@0.4.4, ws@0.7.2)

Introduction

A recent issue that I came across when doing a npm install on a package is the NPM error self signed certificate in certificate chain.

The error message was: npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN

This can lead to SSL cert chain hell! This post I will over a few steps that we can take to resolve this error.

To fix the “npm self signed certificate chain” error, you can try one of the following solutions

  1. Upgrade Node and NPM version or let NPM to use known registrars npm install npm -g --ca=null
  2. Use the command export NODE_TLS_REJECT_UNAUTHORIZED=0
  3. Configure npm to use a specific certificate file: npm config set cafile path/to/cacert.pem
  4. If you are behind a proxy, you may need to configure npm to use it: npm config set proxy http://proxy:port
  5. Use the strict-ssl flag: npm config set strict-ssl false or npm install --strict-ssl false <package_name>

The full error looks something like the following:

npm ERR! Error: SSL Error: SELF_SIGNED_CERT_IN_CHAIN
npm ERR!     at ClientRequest.<anonymous> (/usr/lib/node_modules/npm/node_modules/request/main.js:252:28)
npm ERR!     at ClientRequest.emit (events.js:67:17)
npm ERR!     at HTTPParser.onIncoming (http.js:1261:11)
npm ERR!     at HTTPParser.onHeadersComplete (http.js:102:31)
npm ERR!     at CleartextStream.ondata (http.js:1150:24)
npm ERR!     at CleartextStream._push (tls.js:375:27)
npm ERR!     at SecurePair.cycle (tls.js:734:20)
npm ERR!     at EncryptedStream.write (tls.js:130:13)
npm ERR!     at Socket.ondata (stream.js:38:26)
npm ERR!     at Socket.emit (events.js:67:17)
npm ERR! Report this *entire* log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>
npm ERR! 
npm ERR! System Linux 2.6.38-13-generic
npm ERR! command "node" "/usr/bin/npm" "install" "jed"
npm ERR! node -v v0.6.12
npm ERR! npm -v 1.0.104

What does error SELF_SIGNED_CERT_IN_CHAIN mean?

When we come up with this error, it usually means that we are install a package from NPM that contains a self signed certificate. Self signed certificates in the certificate chain are not trusted by the system and therefore gives this error.

Sometimes the cause of this can be using a private NPM package repository, and that repo does not have the right SSL cert.

1. Upgrade Node and NPM version or let NPM to use known registrars!

One of the reason for this to occur is that with old versions of Node and NPM, they used a self signed certificate!

The npm client used a certificate authority (CA) file that was bundled into the client itself. This was previously necessary because the client used a self-signed SSL certificate.

However, NPM clients after Feb 2014 should not use self-signed SSL certificates anymore, so should not have this problem (https://blog.npmjs.org/post/78085451721/npms-self-signed-certificate-is-no-more).

To fix this issue, we need to update our NPM client.

Run the following to update your NPM client:

npm install npm -g --ca=null

Then additionally, run the following to set ther certificate authority:

npm config set ca=""

This just means to let NPM not use the bundled SSL that was not working.

If this does not work, upgrade to the latest version of node.js — since the latest stable version of node includes the NPM client that does not have this issue.

We can set environment variable NODE_TLS_REJECT_UNAUTHORIZED to be zero:

Open up the terminal and run the following code (for Unix):

export NODE_TLS_REJECT_UNAUTHORIZED=0

For Windows, edit this environment variable in System Properties. You can also open up the command line and run:

set NODE_TLS_REJECT_UNAUTHORIZED=0

This variable just tells node to disable certificate verification — thus making your TLS or HTTPS connection insecure.

Although not ideal security wise, but if you want to get code working quickly and sure that your system is not exposed!

3. Configure npm to use a specific certificate file

If you trust the host, you can export the self signed SSL certificate and either:

  • tell NPM to trust our self signed SSL certificate as well, or
  • add it to your certificate store on your system and mark it as trusted.

Exporting the self signed SSL certificate

For example, we are using chrome and assuming the repo is https://registry.npmjs.org/ (this can be your own private self signed repo):

  1. Click on the padlock icon at the left

image of how to view ssl certificate

  1. Click on the “Connection is secure” link
  2. Click on “Certificate is valid” link
  3. Go to the details tab and hit export into a .cer or .crt file.

image of download the ssl certificate

  1. Combine all the certificates as-is into one .cer or .crt file.
  2. Put this file into a folder that you have access to. In my case I placed it in “C:temptrustedcert.cer”

Configure NPM to trust the exported self signed SSL certificate

After we have successfully export the cert, open up the command line and run the following to let NPM trust that cert:

npm config set cafile "C:temptrustedcert.cer"

Then we can run npm install without the SSL self signed cert issue.

Extending trusted certs

The command npm config set cafile <certfilepath>, tells npm to only use the certs provided in that file, instead of extending the existing ones with it.

We can set the environment variable NODE_EXTRA_CA_CERTS to extend pre-defined certs:

NODE_EXTRA_CA_CERTS to "<path to certificate file>"

4. If you are behind a proxy, check proxy settings

This issue can come up if we are behind a corporate proxy that wants to strip HTTPS.

Coporate proxies usually want to do this to “check for viruses” or whatever random reason :)

Image on how proxys work

Clear current proxy settings

Firstly, run the following commands to clear your current proxy settings:

npm config rm proxy

npm config rm https-proxy

Set new proxy settings

After we have cleared the existing proxy settings, we first need to make sure that we set the registry:

npm config set registry https://registry.npmjs.org/

Now set the new proxy settings with the following commands. Replace the proxyname with your corporate proxy URL.

npm config set proxy http://username:password@proxyname:8080

npm config set https-proxy http://username:password@proxyname:8080

Keep in mind that when you are using username and password, they need to be encoded. For example, if your password is: Welcome@12# then it will be like Welcome%4012%23.

Additionally, with your username, you may need to also include the domain name + username aswell.

For example, lets say we work at a company with domain BIGCORP and your username is johnnyweekend with password Welcome@12#, then your NPM proxy config might look something like this:

npm config set proxy http://bigcorp\jonnyweekend:Welcome%4012%23@bigcorpproxy:8080

Tip: Check your corporate proxy settings and make sure that they are not blocking NPM registry

Check with your corporate network team that the proxy is not blocking the following URL: https://registry.npmjs.org

5. Use the strict-ssl flag

This is the last resort option and the above steps did not resolve your issue. We can use the strict-ssl and set it to false to tell NPM to not validate certificates.

This would mean that your TLS or HTTPS connections are not secure over NPM and risk of getting man in the middle attacks.

If you are sure about your system and ok to take that risk, we can run the following:

npm config set strict-ssl false

Summary

In this article, I went over the issue of NPM error of self signed cert in chain. This error is commonly due to the certificate chain containing a self signed certificate that is not trusted.

Usually this happens because we have a previous version of NPM or Node — in this case we need to upgrade to the latest version.

Another cause of this is due to NPM being behind a corporate proxy and not trusting the self signed cert. We can then update our proxy settings, download the certificates and tell NPM to trust it!

The last ditch effort to fix this is to use the strict-ssl flag and set it to false. This just tells npm to not validate certs and exposes us to TLS and HTTPS calls not being encrypted! However this will work if you are ok to accept the risks!

Problem

I encountered the following error while trying to run electron-rebuild on the electron-quick-start application:

gyp ERR! stack Error: self signed certificate in certificate chain

Here’s the extended command output with the error:

$ ./node_modules/.bin/electron-rebuild
✖ Rebuild Failed
An unhandled error occurred inside electron-rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.5.0
gyp info using node@6.9.4 | darwin | x64
gyp http GET https://atom.io/download/electron/v1.4.15/iojs-v1.4.15.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1079:38)
gyp ERR! stack     at emitNone (events.js:86:13)
gyp ERR! stack     at TLSSocket.emit (events.js:185:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:603:8)
gyp ERR! stack     at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:433:38)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/usr/local/bin/node" "/private/tmp/electron-quick-start/node_modules/.bin/node-gyp" "rebuild" "--target=1.4.15" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/private/tmp/electron-quick-start/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.8/{toolset}/" "--package_name=electron-v1.4-darwin-x64.tar.gz"
gyp ERR! cwd /private/tmp/electron-quick-start/node_modules/sqlite3
gyp ERR! node -v v6.9.4
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok

Failed with exit code: 1

Error: gyp info it worked if it ends with ok
gyp info using node-gyp@3.5.0
gyp info using node@6.9.4 | darwin | x64
gyp http GET https://atom.io/download/electron/v1.4.15/iojs-v1.4.15.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: self signed certificate in certificate chain
gyp ERR! stack     at Error (native)
gyp ERR! stack     at TLSSocket.<anonymous> (_tls_wrap.js:1079:38)
gyp ERR! stack     at emitNone (events.js:86:13)
gyp ERR! stack     at TLSSocket.emit (events.js:185:7)
gyp ERR! stack     at TLSSocket._finishInit (_tls_wrap.js:603:8)
gyp ERR! stack     at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:433:38)
gyp ERR! System Darwin 15.6.0
gyp ERR! command "/usr/local/bin/node" "/private/tmp/electron-quick-start/node_modules/.bin/node-gyp" "rebuild" "--target=1.4.15" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=/private/tmp/electron-quick-start/node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.8/{toolset}/" "--package_name=electron-v1.4-darwin-x64.tar.gz"
gyp ERR! cwd /private/tmp/electron-quick-start/node_modules/sqlite3
gyp ERR! node -v v6.9.4
gyp ERR! node-gyp -v v3.5.0
gyp ERR! not ok

Failed with exit code: 1
    at SafeSubscriber.obs.subscribe.e [as _error] (/private/tmp/electron-quick-start/node_modules/spawn-rx/lib/index.js:311:43)
    at SafeSubscriber.__tryOrUnsub (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:223:16)
    at SafeSubscriber.error (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:184:26)
    at Subscriber._error (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:128:26)
    at Subscriber.error (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:102:18)
    at MapSubscriber.Subscriber._error (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:128:26)
    at MapSubscriber.Subscriber.error (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:102:18)
    at SafeSubscriber.pipesClosed.subscribe [as _next] (/private/tmp/electron-quick-start/node_modules/spawn-rx/lib/index.js:284:42)
    at SafeSubscriber.__tryOrUnsub (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:223:16)
    at SafeSubscriber.next (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:172:22)
    at Subscriber._next (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:125:26)
    at Subscriber.next (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:89:18)
    at ReduceSubscriber._complete (/private/tmp/electron-quick-start/node_modules/rxjs/operator/reduce.js:116:30)
    at ReduceSubscriber.Subscriber.complete (/private/tmp/electron-quick-start/node_modules/rxjs/Subscriber.js:114:18)
    at MergeAllSubscriber.notifyComplete (/private/tmp/electron-quick-start/node_modules/rxjs/operator/mergeAll.js:105:30)
    at InnerSubscriber._complete (/private/tmp/electron-quick-start/node_modules/rxjs/InnerSubscriber.js:30:21)

Solution

I simply connected to my work VPN.

Personally, the minute I see any kind of SSL certificate error I immediately know it’s because 1) I’m on a work computer and 2) I’m on the work WiFi network.

Problem is… I usually don’t know what is the “right” solution (ha ha!).

I can’t say I really understand the problems most of the time, but thankfully this time the solution was straightforward — just connecting to the work network. Perhaps the “self signed certificate” in this case requires verification by a corporate server that I can only access over VPN. More investigation would be helpful…

If you’re looking for other solutions, please take a look at ERR! self signed certificate in certificate chain #7519 and the other referenced issues at the bottom in Github.

by Vlad Turiceanu

Passionate about technology, Windows, and everything that has a power button, he spent most of his time developing new skills and learning more about the tech world. Coming… read more


Updated on January 17, 2023

  • Since npm stopped automatically accepting self-signed certificates, users have started to report errors while trying to publish some packages in certain applications.
  • The error can be fixed, usually, by upgrading the package manager or use the known registrars.

error: self signed certificate in certificate chain

XINSTALL BY CLICKING THE DOWNLOAD FILE

To fix various PC problems, we recommend Restoro PC Repair Tool:
This software will repair common computer errors, protect you from file loss, malware, hardware failure and optimize your PC for maximum performance. Fix PC issues and remove viruses now in 3 easy steps:

  1. Download Restoro PC Repair Tool that comes with Patented Technologies (patent available here).
  2. Click Start Scan to find Windows issues that could be causing PC problems.
  3. Click Repair All to fix issues affecting your computer’s security and performance
  • Restoro has been downloaded by 0 readers this month.

For some time now, developers encountered a SELF_SIGNED_CERT_IN_CHAIN error during installing and publishing packages in certain applications and developer tools such as Node.js, npm, or Git.

Until a few years ago, when npm for instance announced that they would no longer support self-signed certificates.

This means that the certificate verification process was no longer automatic. So developers now have to set up their application to see the self-signed certificates.


How do I fix self-signed certificate in the certificate chain?

self signed certificate in certificate chain

Depending on the tool you’re using, there are a few recommendations. Some are risky, some are safe. One thing is clear, though: you should not attempt to disable the certification verification process altogether.

For Node.js

You can insert an environment variable to allow untrusted certificates using the following command at the beginning of the code:

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = 0;

This is risky and it’s not recommended to be used in production. Alternatively, use npm config set strict-ssl=false if you have to do this for many applications and you want to save repeating the process.

Users also suggest upgrading your version of Node, to fixes any existing bugs and vulnerabilities.


For npm

The recommended solution is, again, to upgrade your version of npm running one of the following:

npm install npm -g --ca=null 

npm update npm -g

Or,  tell your current version of npm to use known registrars, and after installing, stop using them:

npm config set ca ""
npm install npm -g
npm config delete ca

Some users mentioned that they only switched the registry URL from https to http:

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

We hope that one of these suggestions helped you fix the problem. Should you have any recommendations, please use the comments section below.



newsletter icon

Понравилась статья? Поделить с друзьями:
  • Selenium ошибка cannot find chrome binary
  • Sea of thieves ошибка видеодрайвера
  • Selected boot image did not authenticate ошибка
  • Sea of thieves ошибка video driver
  • Select main output device a1 ошибка