Installation of certificate in all Node products

מתוך ויקי נטפרי
גרסה מ־22:48, 31 באוקטובר 2018 מאת שלו' (שיחה | תרומות) (יצירת דף עם התוכן "<div lang="en" dir="ltr" class="mw-content-ltr"> <div lang="he" dir="rtl"> לעברית לחצו כאן </div>...")
(הבדל) → הגרסה הקודמת | הגרסה האחרונה (הבדל) | הגרסה הבאה ← (הבדל)
קפיצה לניווט קפיצה לחיפוש

לעברית לחצו כאן

Home page > Security certificate > Installation of certificate in all Node products

Download the certificate of your Provider of NetFree from here. http://netfree.link/netfree-ca.crt Save it on your computer where you want but in a fixed place.

Configure on your computer an Environment variable named NODE_EXTRA_CA_CERTS, whose value is the certificate address on the computer.

(To define an environment variable in the system Windows, write in a command prompt opened in administrator mode:

SetX NODE_EXTRA_CA_CERTS "C:\netfree-ca.crt" /m

Of course you have to change "C:\netfree-ca.crt" to the correct folder where the certificate was saved.

In Linux systems, open the profile file (/etc/profile) And write the following line at the end of the file:

export NODE_EXTRA_CA_CERTS=/netfree-ca.crt

Here too, verify that the certificate is in / or write the folder where it is located).


If the setting does not work because it is an old version or it is electron, add this code somewhere in the software.

(function(){
	if(!process.env.NODE_EXTRA_CA_CERTS) return;
	try{
		var netfreeCa = require("fs").readFileSync(process.env.NODE_EXTRA_CA_CERTS);
	}catch(e){
		return;
	}
	
	var NativeSecureContext = process.binding('crypto').SecureContext;
	var oldaddRootCerts = NativeSecureContext.prototype.addRootCerts;
	NativeSecureContext.prototype.addRootCerts = function(){
		var ret = oldaddRootCerts.apply(this,arguments);
		this.addCACert(netfreeCa);
		return ret;
	};
})();


Alternatively you can also cancel the need for a certificate by canceling security, on every node run and things based on it:


Run at the command prompt.

In Linux

export NODE_TLS_REJECT_UNAUTHORIZED=0

In Windows

set NODE_TLS_REJECT_UNAUTHORIZED=0


And then run the Node.