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)

Most upvoted comments

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.

wget --no-check-certificate https://cdn.cypress.io/desktop/9.5.3/linux-x64/cypress.zip -O ~/cypress.zip
CYPRESS_INSTALL_BINARY=~/cypress.zip npm install cypress --save-dev

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’s process.env is not populated by the .npmrc that is configured with npm config set. process.env is 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:

export npm_config_cafile=/etc/pki/tls/certs/ca-bundle.crt
export CYPRESS_DOWNLOAD_USE_CA=1

This sets the bash environment variables which will be read correctly by cypress’ postInstall. So even if you run npm config get cafile and 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 with npm_config_. When I tried this, I could not find the relevant variables until setting them using export.

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.

/bin/curl -o /nix/npm.certs.pem https://curl.se/ca/cacert.pem
/bin/npm config set cafile /nix/npm.certs.pem
export SSL_CERT_FILE="/nix/npm.certs.pem"
...
npm ERR! ----------
npm ERR!
npm ERR! URL: https://download.cypress.io/desktop/13.3.3?platform=linux&arch=x64
npm ERR! Error: unable to get local issuer certificate
npm ERR!
npm ERR! ----------

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.

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.

wget --no-check-certificate https://cdn.cypress.io/desktop/9.5.3/linux-x64/cypress.zip -O ~/cypress.zip
CYPRESS_INSTALL_BINARY=~/cypress.zip npm install cypress --save-dev

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)