Languages

Node.js - disable certificate validation

3 points
Asked by:
Kenya-Spears
860

How can I disable certificate validation in Node.js?

1 answer
3 points
Answered by:
Admin Dirask Community
4380

Solution 1

Run Node.js from command line using environemnt variable.

e.g. Bash:

e.g. Windows Command Prompt (cmd.exe):

Note: you can find universal solution here.

 

Solution 2

Use the following line before https.request():

Note: it is recommended to paste it at the beginning of application.

 

Solution 3

Alternatively, in request options you can set rejectUnauthorized to false value:

 

Warning:

Disabling certificate validation disables all kinds of security checks, don't use it in production environment. Use this solutions for testing purposes only.

 

References

  1. HTTPS | Node.js v19.6.0 Documentation
0 commentsAdd comment
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join