node-gyp: Error: self signed certificate in certificate chain
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_modules\protractor\node_modules\selenium-webd
river\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild
.\node_modules\protractor\node_modules\selenium-webdriver\node_modules\ws\node_modu
les\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\\..
\..\node_modules\node-gyp\bin\node-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_modules\protractor\node_modules\selenium-webdriver\node_modules
\ws\node_modules\utf-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_modules\protractor\node_modules\selenium-webdrive
r\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild
.\node_modules\protractor\node_modules\selenium-webdriver\node_modules\ws\node_modu
les\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\\..\..\
node_modules\node-gyp\bin\node-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_modules\protractor\node_modules\selenium-webdriver\node_modules
\ws\node_modules\bufferutil
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_modules\protractor
├── 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_modules\protractor\node_modules\selenium-webdrive
r\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild
.\node_modules\protractor\node_modules\selenium-webdriver\node_modules\ws\node_modu
les\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\\..\..\
node_modules\node-gyp\bin\node-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_modules\protractor\node_modules\selenium-webdriver\node_modules
\ws\node_modules\bufferutil
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_modules\protractor\node_modules\selenium-webd
river\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild
.\node_modules\protractor\node_modules\selenium-webdriver\node_modules\ws\node_modu
les\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\\..
\..\node_modules\node-gyp\bin\node-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_modules\protractor\node_modules\selenium-webdriver\node_modules
\ws\node_modules\utf-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_modules\protractor
├── 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_modules\protractor\node_modules\selenium-webd
river\node_modules\ws\node_modules\utf-8-validate
> node-gyp rebuild
.\node_modules\protractor\node_modules\selenium-webdriver\node_modules\ws\node_modu
les\utf-8-validate>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\\..
\..\node_modules\node-gyp\bin\node-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_modules\protractor\node_modules\selenium-webdriver\node_modules
\ws\node_modules\utf-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_modules\protractor\node_modules\selenium-webdrive
r\node_modules\ws\node_modules\bufferutil
> node-gyp rebuild
.\node_modules\protractor\node_modules\selenium-webdriver\node_modules\ws\node_modu
les\bufferutil>if not defined npm_config_node_gyp (node "C:\Program Files\iojs\node_modules\npm\bin\node-gyp-bin\\..\..\
node_modules\node-gyp\bin\node-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_modules\protractor\node_modules\selenium-webdriver\node_modules
\ws\node_modules\bufferutil
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_modules\protractor
├── 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)
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 17
- Comments: 78 (6 by maintainers)
node-gyp doesn’t use the npm registry, it downloads the tarball from https://nodejs.org/.
Setting
NODE_TLS_REJECT_UNAUTHORIZED=0
in the environment will disable verification but you are setting yourself up for a MitM attack. Closing, not a bug but a feature.from command line you can do: set NODE_TLS_REJECT_UNAUTHORIZED=0 npm install [mypackage]
why close this? it seems to be a pretty common issue for a lot of people downloading packages that require node-gyp, and I just installed newest nodejs and npm and am still getting this issue. Using the NODE_TLS_REJECT_UNAUTHORIZED=0 may work, but it is a hack fix.
Same problem. It doesn’t seem to be respecting my global configuration settings for some reason. basically impossible to install behind a corporate proxy.
Can this be helpful? git config --global http.sslVerify false
setting NODE_TLS_REJECT_UNAUTHORIZED=0 works
The problems occur because the
install
scripts for those packages callnode
under the hood. When this happens, the proxy / cafile settings fornpm
are not always respected.To work around this without disabling ssl completely, you can try this:
I am on RHEL7 and I tried
export NODE_TLS_REJECT_UNAUTHORIZED=0
but still getting SELF_SIGNED_CERT_IN_CHAIN error. The two modules that are failing to install are bcrypt and libxmljs.Unfortunately where I work no proxy is provided so these variables don’t help. My company plays man in the middle and injects certs and there is nothing I can do about it.
in command line in folder with NPM use this: npm config set strict-ssl false
“Works” in the sense that it undermines TLS. It’s a useful temporary hack and troubleshooting option, but an irresponsible long-term setting. https://www.npmjs.com/browse/keyword/NODE_TLS_REJECT_UNAUTHORIZED = “insecure”
On Wed, Mar 22, 2017, 02:34 Rahul Bisht notifications@github.com wrote:
Excuse my ignorance but how do you use NODE_TLS_REJECT_UNAUTHORIZED=0
I’m on Windows using cmd
Do I set this in the: npm confit set NODE_TLS_REJECT_UNAUTHORIZED=0
Have the same problem with node 4.1 and node-gyp 3.0.3:
Windows users: Having
cafile=C:\path\to\my\companys\cafile.pem
did not work. However removing that line and setting the environment variable below did work:For noobs like me: the .pem file is just the base64 encoded certificates (.cer) of your proxy’s CA root (and intermediate).
No, because I don’t want to disable all certificate validation. Decrypting network hardware (substituting their local certs) are used in high-security environments, and accepting every certificate from any source would radically undermine that.
This would be much better addressed by fixing https://github.com/nodejs/node/issues/3159.
Playing whack-a-mole with npm, Atom, VS code, cUrl, Firefox, &c, &c, &c each using their own cert store when the OS supplies one is an unmanageable mess.
If that’s not immediately supported, a standard cafile environment variable that’s honored by all parties would at least help.
Linux
export NODE_TLS_REJECT_UNAUTHORIZED=0
Windows
set NODE_TLS_REJECT_UNAUTHORIZED=0
i found this comment on another issue and it seems to work https://github.com/nodejs/node-gyp/issues/448#issuecomment-44061248. just set that environment variable. This is a hacky work around though, node-gyp should respect npmrc.
On npm
On Node Package Manager you have two options: bypass or set a certificate file. Bypassing (risky!)
npm config set strict-ssl false --global
Setting a certificate filenpm config set cafile /path/to/your/cert.pem --global
It looks like that error may be thrown also with nodemailer. In my situation with sails my services/EmailService.js was throwing the error upon lift and on send… this stack fixed both issues.
Sorry for the highjack but this thread owns “Error: self signed certificate in certificate chain” in google search
Since node-gyp is a tool for nodejs, but not resides inside of nodejs, I can fully understand why it should not use the node/npm configs for setting the network environment. But I must also agree with the others, that node-gyp should provide it’s (optional) own config file, because in my case the system proxy environment is not enough, too: My company’s proxy also established a MitM scenario, so I need a
strict-ssl=false
.The ‘workaround’ with
NODE_TLS_REJECT_UNAUTHORIZED=0
works, but it is not very user friendly:on windows, version v16.16.0. those are not working Set NODE_TLS_REJECT_UNAUTHORIZED=0 SET NODE_EXTRA_CA_CERTS=C:\path\to\my\companys\cafile.pem
Is there a way to specify where the file should be downloaded from or do I have to hack the hosts file to avoid this blocking issue ?
None of the other methods worked for me (see https://github.com/nodejs/node-gyp/issues/695#issuecomment-1485089294), but this command finally solved the problem (on Windows 11):
$env:NODE_EXTRA_CA_CERTS="C:\path\to\certificate.crt"
node-gyp
andnpm
now work without any problems.I was facing the same issue and realize that the request is actually blocked by firewall. So make sure that the request is accessible from the browser.
env export NODE_TLS_REJECT_UNAUTHORIZED=0 worked for me too!
Hi,
i just can’t install keytar because node-gyp rebuild fails with this problem:
I’ve tried
I do not know what I can try beyond this.
Can anyone recommend a solution?
Try uninstalling Angular/cli first and installing node-gyp and then try reinstalling Angular cli
It worked perfectly
I used Set NODE_TLS_REJECT_UNAUTHORIZED=0 and npm config set strict-ssl false
worked for me
Not working for me, I used following command to se
set NODE_TLS_REJECT_UNAUTHORIZED=0
Can you tell me what more needs to be done ?
your issue is not exactly what is being discussed in this thread and your settings in the npmrc file have not affect on how nodejs is operating… You can use the solutions mentioned above to “fix” your issue.
I work in an environment where our proxies also use this self-signed cert substitution technique. Is there a particular reason to not expect security appliance vendors and operators to start using signed certificates for their appliances? I think the only way we will see a change in behavior is to continue to place that expectation on the vendors and operators. And it’s not just Node that has these “issues” dealing with self-signed certs. Every application I support that interacts with the internet is a headache because of this.
so there is now a command line option to provide ca file … any idea how to engage that when node-gyp is getting called by the NPM install process? i’m not the one calling node-gyp, npm is, via the project file of the module being installed. the solution seems to remain the NODE_TLS_REJECT_UNAUTHORIZED=0 hack.