electron: Cannot install behind corporate firewall
Windows 7:
C:\electron\project\node_modules\electron\install.js:47
throw err
^
Error: unable to get local issuer certificate
at TLSSocket.<anonymous> (_tls_wrap.js:1088:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:188:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
About this issue
- Original URL
- State: closed
- Created 10 years ago
- Reactions: 9
- Comments: 31 (4 by maintainers)
Have you tried with
npm config set strict-ssl false? Im also using a corporate proxy and that worked for me.export NODE_TLS_REJECT_UNAUTHORIZED=0 Worked for me
We recommend you utilize external tools available to you to properly configure your proxy, or do something like
npm config set strict-ssl false. At present, this isn’t something for which the optimal solution presents itself as a change to Electron itself.@codebytere - thank you, we have moved away from trying Electron and went with nwjs. It is just not possible to use Electron in our environment.
To specifically address your suggestions: 1) I can’t change the proxy configuration. It is configured correctly as required by corporate policy. 2) npm works just fine because I have the strict-ssl setting. The issue is the Electron post install script and it cannot be addressed by npm.
Also for me it’s not fixed. trying to download electron 9.0.2 specified an cafile and set the strict-ssl option to false. always getting the electron post install error
> node install.js RequestError: unable to get local issuer certificate at ClientRequest. (C:\Users\userName\Downloads\projectName\packager-test\node_modules\got\source\request-as-event-emitter.js:178:14) at Object.onceWrapper (events.js:422:26) at ClientRequest.emit (events.js:327:22) at ClientRequest.origin.emit (C:\Users\userName\Downloads\projectName\packager-test\node_modules\@szmarczak\http-timer\source\index.js:37:11) at TLSSocket.socketErrorListener (_http_client.js:432:9) at TLSSocket.emit (events.js:315:20) at emitErrorNT (internal/streams/destroy.js:84:8) at processTicksAndRejections (internal/process/task_queues.js:84:21)EDIT: SOLVED by:
set NODE_EXTRA_CA_CERTS=/path/to/issuer/.crtspecify the node_extra_ca_certs for nodejs before downloading electron solved the problem.
Why closed? this issue hasn’t been resolved. I am still getting same issue.
Can you try
Not all of them might be required.
ref https://www.electronjs.org/docs/tutorial/installation#proxies
(replace
http://localhost:8888with your own proxy)Similar issue here. We have an npm cache using aritfactory - that is: We usually do not use the official npm registry but our local one. We have to do this because our corporate proxy needs authentication.
Of course this won’t work as long as the post-install script tries to download something itself.
Hard coding the proxy credentials in the configuration file for my local PC is bad. Doing this in our CI system is impossible. I currently see two options:
PS.: We’re currently working on Windows7
EDIT: Simply setting
$env:NODE_TLS_REJECT_UNAUTHORIZED=0before the electron install ended up working. Then even after setting it back to 1, everything works as normal. But I will leave my original workaround below in case it still helps someone.Everyone, this is not an Electron issue. NPM/Electron cannot connect to some external URL through your corporate proxy server, because it doesn’t trust your corporate proxy’s root certificates. If you are on a team then probably they already have a guide for how to set it up, ask your IT or team leader about it.
DO NOT set NODE_TLS_REJECT_UNAUTHORIZED=0 this is insecure. You should not be connecting to servers with untrusted CAs. This setting is there to protect you from downloading insecure or unverified packages. Everyone has heard this a million times and still people do it because it’s easier. If you’re using this, every time you install or update a package it puts your project at risk.
@h3llsing You need root CA certificates…someone in IT or sth will know what they are. You can maybe check them in your Windows cert store (Trusted Root Certification Authorities) but it’s probably easier to ask some senior team member. From Windows cert store you can export each root cert as .crt (not PEM or DER) and then proceed as below. We have several root CAs for different levels of security, so I setup NPM to trust all of them:
Windows command line:
If you have VS Code open, close and re-open after changes (need to do this for PATH setting)
At this point everything should work, because NPM and Electron will trust your corporate certs defined in NODE_EXTRA_CA_CERTS variable.
If it doesn’t work, you can try defining your corporate proxy URLs for Node to use:
If you connect manually to a corporate VPN, when you are connected/disconnected you will need to CHANGE your http_proxy & https_proxy to use the required URL.
So ex. we have locally installed proxy with one URL, and VPN proxy with another URL. If you have static URL set in Windows proxy settings, this is probably the URL you want. If you have a script in there then you’ll need a different proxy URL at different times, based on some conditions the script is checking (ie. if you’re connected to VPN or not). Make sure you don’t copy the proxy script address and try to use it as the proxy URL.
If, after everything, it still doesn’t work, maybe your corporate proxy is blocking the traffic. Make sure you as a user have the rights to use NPM.
Works.