Install root certificate to Node.js (HTTPS Client)

Add an environment variable:

NODE_EXTRA_CA_CERTS=file

When set, the well known "root" CAs (like VeriSign) will be extended with the extra certificates in file. The file should consist of one or more trusted certificates in PEM format. A message will be emitted (once) with process.emitWarning() if the file is missing or malformed, but any errors are otherwise ignored.

Note that neither the well known nor extra certificates are used when the ca options property is explicitly specified for a TLS or HTTPS client or server.

This environment variable is ignored when node runs as setuid root or has Linux file capabilities set.


I solved the problem.

Use this, it works as charm: https://github.com/coolaj86/node-ssl-root-cas

  1. Create a certificates folder
  2. Place your root certificate there
  3. Load the certificate with the module metnioned above

If you use Sails.js, put the code to config/bootstrap.js