Node.JS Error-process.env.NODE_TLS_REJECT_UNAUTHORIZED. What does it mean?

I am new to back-end development. And I really like writing code in node. However, there are a few things that I simply cannot understand. I kept getting the following error:

Error: DEPTH_ZERO_SELF_SIGNED_CERT

I fixed it by running the following code:

if ('development' == app.get('env')) { console.log("Rejecting node tls"); process.env.NODE_TLS_REJECT_UNAUTHORIZED = "0"; } 

I understand that we are setting up the environment. But what does this mean in plain language? I do not know how to explain this to someone else. There is a lot of information on how to fix this, but I can not find anything about what this means.

Can someone explain?

+6
source share
1 answer

Node complains because the TLS (SSL) certificate it gave is self-signed (i.e. it does not have a parent - depth 0). He expects to find a certificate signed by another certificate that is installed in your OS as a trusted root.

“Fix” - disable Node from rejecting self-signed certificates by allowing ANY unauthorized certificate.

Your correction is unsafe and should not be performed at all, but is often done in development (it should never be done in production).

The right decision should be to put the self-signed certificate in a trusted root store or get the proper certificate signed by an existing certificate authority (which is already trusted to your server).

As an additional point in your journal should be indicated "Disabling Node rejection of invalid / unauthorized certificates"

+9
source

All Articles