WakandaKing
WakandaKing

Reputation: 61

How can I set NODE_EXTRA_CA_CERTS on node

I am trying to set extra CAs for my nodejs project, I tried using " set NODE_EXTRA_CA_CERTS={directorty}/ca.pem" but the nodejs project still cannot pick up the set env variable.

How can set this variable?

Upvotes: 3

Views: 33288

Answers (1)

Michael
Michael

Reputation: 351

Used the answer from https://stackoverflow.com/a/56239954/3700823 myself.

On windows you should backslashes instead of slashes. And make sure you use the full path (like set NODE_EXTRA_CA_CERTS=C:\stuffed\subfolder\thefile.pem). Though some mention relative path (like set NODE_EXTRA_CA_CERTS=.\subfolder\thefile.pem) should work as well, not tested myself. Maybe that's only valid for *nix.

Then either try restart node.exe, or the machine to make sure node.exe starts using the environment variable. For me it began to work after rebooting.

As the nodejs documentation mentions, nodejs should warn you once about any issue. Check the official documentation: https://nodejs.org/api/cli.html#node_extra_ca_certsfile

Upvotes: 5

Related Questions