cypress: Error: unable to get local issuer certificate
Issue
When installing cypress via node on a restrictive network at a large corp, I receive the following error:
The Cypress App could not be downloaded.
Please check network connectivity and try again:
----------
URL: https://download.cypress.io/desktop/2.0.2?platform=darwin&arch=x64 …
Error: unable to get local issuer certificate
----------
Platform: darwin (16.7.0)
Cypress Version: 2.0.2
Accessing the link directly works. Also I can WGET and Curl the link without issue.
I tried setting NODE_TLS_REJECT_UNAUTHORIZED=0 but that didn’t seem to resolve the issue. My corporate security team asked:
They using their own CA store in the downloader? NODE_TLS_REJECT_UNAUTHORIZED=0 usually fixes that unless they use their own CA bundle, which would 100% break in our environment."
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Reactions: 3
- Comments: 15 (3 by maintainers)
If you run into this problem due to corp firewall rules and are using WSL, you can do this to work around. Change the version as needed.
Okay, so I think I figured it out for myself. I am behind a corporate firewall and need to set custom ca certificates.
Based on this function when cypress downloads itself it attempts to use the npm ca or cafile settings from
process.env, however, on my system and apparently other people’sprocess.envis not populated by the.npmrcthat is configured withnpm config set.process.envis only the result of the environment variables, which npm also uses but doesn’t use alone.To address the issue I had to run these two lines:
This sets the bash environment variables which will be read correctly by cypress’ postInstall. So even if you run
npm config get cafileand it returns an answer, if you do not set these environment variables as well, cypress will fail. You can check this before setting the variables by running.node -e "console.log(process.env)"and looking for settings prefixed withnpm_config_. When I tried this, I could not find the relevant variables until setting them usingexport.node doesn’t provide a builtin package to get the settings inside of itself by default, but a user named kevva seems to have created a package to get settings the same way npm does. It was forked and is now more recently maintained by the pnpm project here though.
If cypress would like to use it, it works like this after you install it:
node -e "require('@pnpm/npm-conf')().config.get('cafile')"It seems like this kind of problem comes up a lot: https://github.com/cypress-io/cypress/issues/17238 https://github.com/cypress-io/cypress/issues/1401 https://github.com/cypress-io/cypress/issues/7107
Good luck everyone.
npm install cypress is failing, I am using windows 10 64 bit and our company uses zscaler ,Can someone help ? Installing Cypress (version: 7.7.0)
The Cypress App could not be downloaded.
Does your workplace require a proxy to be used to access the Internet? If so, you must configure the HTTP_PROXY environment variable before downloading Cypress. Read more: https://on.cypress.io/proxy-configuration
Otherwise, please check network connectivity and try again:
URL: https://download.cypress.io/desktop/7.7.0?platform=win32&arch=x64 Error: unable to get local issuer certificate
Platform: win32 (10.0.18363) Cypress Version: 7.7.0 npm WARN TODOMVC-TESTS@1.0.0 No description npm WARN TODOMVC-TESTS@1.0.0 No repository field.
I am getting this error despite having certs installed.
As you can see, I both register the certs with npm and set the environment variable. It cleared up all other cert problems beside this one. And I am not behind a corporate firewall.
Please reopen.
Be careful when using options like
--no-check-certificate. It’s basically saying, “download the file with your eyes closed”. It’s a dangerous workaround that allows a window for hackers. It’s not likely you’ll get hacked, but it’s bad practice to disable security to “just make things work”.@helloworld121
This stackoverflow answer may be better for you than my other answer. I’m not sure how NPM manages certificates, maybe it doesn’t use the OS’s. Good luck!
https://stackoverflow.com/a/30341389/209003
Yeah, it might be your own network proxy that acts like man in the middle while downloading from external sources (at least that’s my understanding from reading reports about such issues here https://github.com/nodejs/help/issues/979)