Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to disable strict ssl #448

Closed
kevinsawicki opened this issue May 23, 2014 · 7 comments
Closed

Add option to disable strict ssl #448

kevinsawicki opened this issue May 23, 2014 · 7 comments

Comments

@kevinsawicki
Copy link
Contributor

This doesn't seem to be possible currently when running node-gyp install.

Being able to disable strict SSL on the download request would prevent this error (I hope):

gyp info it worked if it ends with ok
gyp info using node-gyp@0.12.2
gyp info using node@0.10.26 | darwin | x64
gyp http GET https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist/v0.11.10/node-v0.11.10.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! install error 
gyp ERR! stack Error: UNABLE_TO_VERIFY_LEAF_SIGNATURE
gyp ERR! stack     at SecurePair.<anonymous> (tls.js:1370:32)
gyp ERR! stack     at SecurePair.EventEmitter.emit (events.js:92:17)
gyp ERR! stack     at SecurePair.maybeInitFinished (tls.js:982:10)
gyp ERR! stack     at CleartextStream.read [as _read] (tls.js:469:13)
gyp ERR! stack     at CleartextStream.Readable.read (_stream_readable.js:320:10)
gyp ERR! stack     at EncryptedStream.write [as _write] (tls.js:366:25)
gyp ERR! stack     at doWrite (_stream_writable.js:226:10)
gyp ERR! stack     at writeOrBuffer (_stream_writable.js:216:5)
gyp ERR! stack     at EncryptedStream.Writable.write (_stream_writable.js:183:11)
gyp ERR! stack     at write (_stream_readable.js:583:24)
gyp ERR! System Darwin 13.1.0
gyp ERR! command "/Users/dgillhespy/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/bin/node" "/Users/dgillhespy/Applications/Atom.app/Contents/Resources/app/apm/node_modules/atom-package-manager/node_modules/node-gyp/bin/node-gyp.js" "install" "--target=0.11.10" "--dist-url=https://gh-contractor-zcbenz.s3.amazonaws.com/atom-shell/dist" "--arch=x64"
gyp ERR! cwd /Users/dgillhespy/.atom
gyp ERR! node -v v0.10.26
gyp ERR! node-gyp -v v0.12.2
gyp ERR! not ok 
@TooTallNate
Copy link
Contributor

Try invoking node-gyp with NODE_TLS_REJECT_UNAUTHORIZED=0.

@AlexLich
Copy link

Hello @TooTallNate!
I'm Sorry, can you tell where to register it? Not in the .npmrc file? I've been struggling with him for 4 days :(

@tigersaggy
Copy link

From command line
set NODE_TLS_REJECT_UNAUTHORIZED=0
and then you can run
npm install

@Zoe314
Copy link

Zoe314 commented Jul 15, 2019

Hello, I have also encountered this problem,My computer is windows7
Stack Error: self signed certificate in certificate chain
    Gyp ERR! stack at TLSSocket.onConnectSecure (_tls_wrap.js:1051:34)
    Gyp ERR! stack at TLSSocket.emit (events.js:189:13)
    Gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:633:8)...
I tried npm config set ca=null; NODE_TLS_REJECT_UNAUTHORIZED=0; npm set strict-ssl false;
Re-uninstall the global node-gyp, reload, but still does not solve the problem, I also updated the npm version; also executed the following command: npm config set ca ""
Npm install npm -g
Npm config delete ca
The contents of my .npmrc file are:
Ca = ""
Msvs_version = "2015"
Python = "python2.7"
Registry = "http://registry.npm.taobao.org/"
Strict-ssl = false

When I execute npm install, I still report this error. The above action does not work. I am very anxious. People who want to know can help me. My error is this:
  ⨯ cannot execute cause=exit status 1
                    Out=
    > pcsclite@0.6.0 install C:\codeing\demo\node_modules\pcsclite
    > node-gyp rebuild

    C:\codeing\NfcClientTool\ClientTool\node_modules\pcsclite>if not defined npm_config_node_gyp (node ​​"C:\Users\houhongf\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\ ....\node_modules\node-gyp\bin\node-gyp.js" rebuild ) else (node ​​"C:\Users\hf\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin \node-gyp.js" rebuild )

                    errorOut=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 TLSSocket.onConnectSecure (_tls_wrap.js:1051:34)
    Gyp ERR! stack at TLSSocket.emit (events.js:189:13)
    Gyp ERR! stack at TLSSocket._finishInit (_tls_wrap.js:633:8)
    Gyp ERR! System Windows_NT 6.1.7601
    Gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\hf\AppData\Roaming\npm\node_modules\npm\node_modules\node -gyp\bin\node-gyp.js" "rebuild"
    Gyp ERR! cwd C:\codeing\demo\node_modules\pcsclite
    Gyp ERR! node -v v10.15.3
    Gyp ERR! node-gyp -v v5.0.2
    Gyp ERR! not ok
    Npm ERR! code ELIFECYCLE
    Npm ERR! errno 1
    Npm ERR! pcsclite@0.6.0 install: node-gyp rebuild
    Npm ERR! Exit status 1
    Npm ERR!
    Npm ERR! Failed at the pcsclite@0.6.0 install script.
    Npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    Npm ERR! A complete log of this run can be found in:
    Npm ERR! C:\Users\hf\AppData\Roaming\npm-cache_logs\2019-07-15T09_54_57_333Z-debug.log

                    Command='C:\Program Files\nodejs\node.exe' 'C:\Users\hf\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js' rebuild buffertools@2.1.6 pcsclite@0.6 .0 sqlite3@4.0.9
                    workingDir=
Npm ERR! code ELIFECYCLE
Npm ERR! errno 1
Npm ERR! client-tool@1.0.0 postinstall: electron-builder install-app-deps
Npm ERR! Exit status 1
Npm ERR!
Npm ERR! Failed at the demo-tool@1.0.0 postinstall script.
Npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Thank you very much! God bless you!

@wtfiwtz
Copy link

wtfiwtz commented Oct 16, 2020

For Windows users, at an elevated command prompt:

cd %USERPROFILE%\.windows-build-tools
msiexec /i python-2.7.15.amd64.msi

You can probably also add /qb to msiexec if you want a silent install.

vs_buildtools.exe can be downloaded from https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=buildtools&rel=16&utm_medium=microsoft&utm_source=docs.microsoft.com&utm_campaign=offline+install&utm_content=download+vs2019

@sereksim
Copy link

Is there a solution that actually works? I tried every suggestion...

set NODE_TLS_REJECT_UNAUTHORIZED=0
npm install -g --unsafe-perm binding
     added 1 package in 13s
npm config set strict-ssl false
set npm_config_cafile "C:\path\to\certificate.pem"
npm config set cafile "C:\path\to\certificate.pem" --global
set NODE_EXTRA_CERTS="C:\path\to\certificate.pem"
set NODE_EXTRA_CA_CERTS="C:\path\to\certificate.pem"

... and node-gyp still fails:

node-gyp configure
gyp info it worked if it ends with ok
gyp info using node-gyp@9.3.1
gyp info using node@18.13.0 | win32 | x64                                                                               
gyp info find Python using Python version 3.9.7 found at "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python39_64\python.exe"                                                                                                         gyp http GET https://nodejs.org/download/release/v18.13.0/node-v18.13.0-headers.tar.gz                                  gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack FetchError: request to https://nodejs.org/download/release/v18.13.0/node-v18.13.0-headers.tar.gz failed, reason: self-signed certificate in certificate chain
gyp ERR! stack     at ClientRequest.<anonymous> (C:\Users\bla\AppData\Roaming\npm\node_modules\node-gyp\node_modules\minipass-fetch\lib\index.js:130:14)
gyp ERR! stack     at ClientRequest.emit (node:events:513:28)
gyp ERR! stack     at TLSSocket.socketErrorListener (node:_http_client:496:9)
gyp ERR! stack     at TLSSocket.emit (node:events:525:35)
gyp ERR! stack     at emitErrorNT (node:internal/streams/destroy:151:8)
gyp ERR! stack     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
gyp ERR! stack     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
gyp ERR! System Windows_NT 10.0.22000
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\bla\\AppData\\Roaming\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "configure"
gyp ERR! cwd C:\Users\bla\my\current\directory
gyp ERR! node -v v18.13.0
gyp ERR! node-gyp -v v9.3.1
gyp ERR! not ok

I also tried to manually download the tar.gz as described here: nodejs/help#3686 (comment), but that didn't change anything. Even if I have the tar.gz file in the \tmp directory, the command fails, because the commands loads multiple files, not only the tar.gz.
Maybe I could load those files manually, but without knowing every file which is downloaded in the process, that doesn't work either. Additionally, installing something with npm install doesn't work either: npm ERR! RequestError: self-signed certificate in certificate chain

This might be connected to the issues nodejs/node#3742, #695 and the already mentioned nodejs/help#3686, but the recommendations there are similar to those here.

@nodejs nodejs deleted a comment from Zoe314 Mar 28, 2023
@sereksim
Copy link

sereksim commented Mar 29, 2023

None of the other methods worked for me (see #448 (comment)), but this command finally solved the problem (on Windows 11):
$env:NODE_EXTRA_CA_CERTS="C:\path\to\certificate.crt"

node-gyp and npm now work without any problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants