linuxnpmcertificateca

How do I configure NPM to use the system certificate authorities in CentOS/RHEL?


How can I configure NPM to use the system certificate bundle in an Enterprise Linux based OS (CentOS/RedHat/etc)?

Additionally, how can I add a custom certificate to this store?


Solution

  • Configuring NPM to use System CAs

    For Enterprise Linux-based systems your certificate store is located at /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem.

    You can configure NPM to globally use this certificate store using:

    npm config set cafile "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem" -g
    

    Adding a Root Certificate to System CA Bundle

    You can install a custom root certificate using the following commands:

    > sudo update-ca-trust
    

    Copy the .crt file you want to add to /etc/pki/ca-trust/source/anchors/

    ONLY if running a 6.x Enterprise Linux variant run the following command: sudo update-ca-trust enable

    Finally, for all variants update the bundle: sudo update-ca-trust extract