Lissy93/web-check

Error: unable to get local issuer certificate

hasanbasri1993 opened this issue · 5 comments

I use local computer then, use Cloudflare Tunnel
from :3050 into domain

But i got error unable to get local issuer certificate

node -v v18.16.1
yarn -v 1.22.19

❯ yarn serve
yarn run v1.22.19
$ node server

__      __   _         ___ _           _   
\ \    / /__| |__ ___ / __| |_  ___ __| |__
 \ \/\/ / -_) '_ \___| (__| ' \/ -_) _| / /
  \_/\_/\___|_.__/    \___|_||_\___\__|_\_\

🚀 Web-Check is up and running at http://localhost:3050

🛟 For documentation and support, visit the GitHub repo: https://github.com/lissy93/web-check
💖 Found Web-Check useful? Consider sponsoring us on GitHub to help fund maintenance & development.
node:events:491
throw er; // Unhandled 'error' event
^

Error: unable to get local issuer certificate
at TLSSocket.onConnectSecure (node:_tls_wrap:1540:34)
at TLSSocket.emit (node:events:513:28)
at TLSSocket._finishInit (node:_tls_wrap:959:8)
at ssl.onhandshakedone (node:_tls_wrap:743:12)
Emitted 'error' event on ClientRequest instance at:
at TLSSocket.socketErrorListener (node:_http_client:502:9)
at TLSSocket.emit (node:events:513:28)
at emitErrorNT (node:internal/streams/destroy:151:8)
at emitErrorCloseNT (node:internal/streams/destroy:116:3)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY'
}

Node.js v18.16.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Big Brain

Big Brain

????

So “unable to get local issuer certificate” typically occurs when Node.js or npm is unable to verify the SSL certificate of the server it’s connecting to. This can happen due to various reasons, such as corporate firewalls, outdated certificates, or strict SSL settings.

So you can maybe try:
1) Disable Strict SSL (Not Recommended for Production)
Run the command to disable strict SSL globally: npm config set strict-ssl false
if you’re using Yarn than : yarn config set "strict-ssl" false

2) Set the NODE_TLS_REJECT_UNAUTHORIZED Environment Variable
Run the command before executing your Node.js script: export NODE_TLS_REJECT_UNAUTHORIZED=0

3) Provide an Extra CA Certificate
If you have a custom CA certificate, you can set the NODE_EXTRA_CA_CERTS environment variable to point to it:
export NODE_EXTRA_CA_CERTS=/path/to/certfile.crt
Replace /path/to/certfile.crt with the actual path to your certificate file.

Note: bypassing SSL validation can expose your connections to security risks. If you’re working in a production environment, consider fixing the underlying issue (such as updating certificates or adjusting firewall settings) rather than disabling SSL checks.

You can watch this YouTube tutorial for more information (Highly recommend):
https://www.youtube.com/watch?v=sgNTXZaZTgw

Wow, that SSL YouTube tutorial is really helpful, I didn't know half that info!

Lol, but in all seriousness, @hasanbasri1993, you can either provide your SSL cert (I'm not sure how that would be done with Cloudflare tunnels), or I think that in Cloudflare if you set SSL mode to Strict / Full, then it should automatically assign SSL. As a workaround, since you're running locally you can also just set NODE_TLS_REJECT_UNAUTHORIZED=0

Closing, as more of a cloudflare question than bug with Web-Check.
But feel free to let me know if that doesn't work out below.