Skip to content

Node uses an hardcoded list of certificate authorities #4175

Description

@fir4

I was dumbfounded when I realized that Node uses a statically compiled, manually updated, hardcoded list of certificate authorities, rather than relying on the system's trust store, or even just a directory truststore of its own.

This causes a large amount of problems :

  • Dependancy on the Node community for reactiveness in addition or removal of certificates
  • Dependancy on the Node community in terms of certificate trust
  • Prevents companies and anyone with their own PKI from using their certificates globally
  • Requires support from EVERY node application making use of SSL to include certificates
  • Requires modification of source code if an application doesn't happen to support it
  • Requires modification and rebuilding of Node to remove certificates that wouldn't be trusted by an organisation

Now, I can see no practical use for that. While this is acceptable in a development environment, where you can make changes to your own application, this is outright unusable... and i can't stress enough the security implications for many organisations.

Proposed solutions :

  • Make use of the standard system trust store, like any sensible application
  • Use a dedicated globally installed trust store, allowing user modifications, and why not, handling with npm
  • Dynamically load CAs using relative path, in a way similar to the usage of the node_modules folder

TL;DR: CA Certificates are hardcoded in node. It may be OK for dev, but it sucks big time for ops.

Activity

  1. added
    tlsIssues and PRs related to the tls subsystem.
    on Dec 7, 2015
  2. kapouer commented on Dec 9, 2015

    @kapouer
    Contributor

    Indeed, a distribution like debian needs to work around that using that kind of patch.

    I already asked this in
    #3159
    I suppose a pull request could make it now ? @fir4 feels like writing one ?

  3. doodadjs commented on Dec 9, 2015

    @doodadjs

    @kapouer Path should not be hard-coded. Also what for other distributions of Linux, and other OSs like Windows and OS X ? This issue requires more research

  4. kapouer commented on Dec 9, 2015

    @kapouer
    Contributor

    I think the simplest thing to do is to have a configurable path as a build option - so that each distributor can point nodejs to the right place where it can find the system-installed root ca(s).
    I don't think it's worth the time spent to be able to change that path at runtime.

  5. fir4 commented on Dec 9, 2015

    @fir4
    Author

    Yeah, those were simple ideas, in case you'd want more flexibility. Using a configurable path on ./configure step would be a great start, however I have literally zero idea how Certificates are handled on MacOS and Windows...

  6. doodadjs commented on Dec 9, 2015

    @doodadjs

    For Windows it's too complicated. It's not just a folder. I'm thinking of a solution... Have a download link to an automatically generated zip file with the CAs. Bundle the current version with each distribution of nodejs. Add an environment variable to nodejs to locate the CAs folder. The installer will extract CAs to a proper location and set the environment variable. For Unix-like systems, the installer may try to locate system CAs. If no installer, this will have to be done manually.

    EDIT: By default, use a build option like kapouer mentionned.

  7. royallabs commented on Dec 12, 2015

    @royallabs

    +1

  8. cpmsmith commented on Jan 8, 2016

    @cpmsmith

    👍

  9. ijstokes commented on Mar 19, 2016

    @ijstokes

    This is a major issue for commercial deployment of nodejs and a major obstacle to our node based software being adopted by large organizations that have their own in-house PKI. It is also indicative of a problem with the node developers lack of understanding of the importance of doing security "right".

    I am very interested in seeing this issue get resolved and if there are sensible ways I can contribute to its resolution, please someone from the NodeJS team let me know (yes, a PR, I realize, but if there is any guidance on how to put that together or other considerations/constraints...)

  10. bnoordhuis commented on Mar 19, 2016

    @bnoordhuis
    Member

    It is also indicative of a problem with the node developers lack of understanding of the importance of doing security "right".

    Please.

    yes, a PR, I realize, but if there is any guidance on how to put that together or other considerations/constraints...

    Start with reading CONTRIBUTING.md. If you still have questions afterwards, I can probably answer them.

  11. bkreider commented on Mar 24, 2016

    @bkreider

    Please.

    Please as in, "please fix this" or "please, it is a super good idea to hard code the list of certificate authorities? "

    this is outright unusable... and i can't stress enough the security implications for many organisations.

    +1.

  12. Fishrock123 commented on Mar 24, 2016

    @Fishrock123
    Contributor

    Please as in, "please fix this" or "please, it is a super good idea to hard code the list of certificate authorities? "

    I Think that was a "Please do not assume things".

  13. bkreider commented on Mar 24, 2016

    @bkreider

    I Think that was a "Please do not assume things".

    Thank you for clarifying.

    One major problem of security is, that most people do not know, how to do it right and do not see all the problems which may arise.

    I agree. Thanks for taking the time to explain.

  14. 7 remaining items

  15. bnoordhuis commented on Jul 4, 2016

    @bnoordhuis
    Member

    I don't get that attitude. You feel strongly enough to complain about it on the bug tracker, apparently strongly enough to switch to a different language but not strongly enough to spend an hour or two on a pull request. The whole point of open source is that you can change it if you don't like what it does.

  16. doodadjs commented on Jul 4, 2016

    @doodadjs

    I have proposed a solution and I think it will be more productive if others do the same or make a pull request instead of just bumping the thread.

  17. mwain commented on Aug 8, 2016

    @mwain
    Contributor

    Had similar issues with this, have internal apps using an internally signed cert.
    Opted to use https.globalAgent and set an array of CA's which are defined in a config and updated on an env basis.

    E.g.

    const trustedCa = [
        '/etc/pki/tls/certs/ca-bundle.crt',
        '/path/to/custom/cert.crt'
    ];
    
    https.globalAgent.options.ca = [];
    for (const ca of trustedCa) {
        https.globalAgent.options.ca.push(fs.readFileSync(ca));
    }
  18. jan-swiecki commented on Aug 17, 2016

    @jan-swiecki

    It turns out that https.request module with ca option doesn't support having multiple certificates in pem file. @DuBistKomisch solution solved this problem. I'm using node v4.

  19. AdamMajer commented on Aug 31, 2016

    @AdamMajer
    Contributor

    #8334 fixes most of this.

  20. sam-github commented on Oct 17, 2016

    @sam-github
    Contributor

    @jan-swiecki In #4175 (comment) you mention that

    It turns out that https.request module with ca option doesn't support having multiple certificates in pem file

    Its not clear if you are talking about a user-land module, but if you are talking about node's https.request() method, I did a some testing, and it supports concatenated PEM certificates in options.ca in node 6.x (which I expected from reading the code), but not node 4.x.

    If you can't upgrade, open an issue about it and make the case that this is a feature that should be back-ported to 4 from 6. I'm not sure what the current stance is on back-porting features, but if its low risk, it may be possible.

  21. SeanHayes commented on Feb 8, 2019

    @SeanHayes

    Setting https.globalAgent.options.ca works for connections to my own server but causes SSL errors for regular connections (which normally work when https.globalAgent.options.ca isn't set). Is there a way to get https.globalAgent.options.ca to append to the default list of certificates used by node?

  22. sam-github commented on Feb 9, 2019

    @sam-github
    Contributor

    Not programmatically, but with env configuration it is: https://nodejs.org/api/cli.html#cli_node_extra_ca_certs_file

  23. nomanmaqsood commented on Aug 12, 2021

    @nomanmaqsood

    @mwain just wanted to understand will https.globalAgent.options.ca.push(fs.readFileSync(ca)); override the globally trusted Nodejs certificates (the Mozilla certificates which come bundled with nodejs as default trusted CA) ?
    and my second concern is will it impact some performance issue?

    Looking forward to your reply

    Had similar issues with this, have internal apps using an internally signed cert.
    Opted to use https.globalAgent and set an array of CA's which are defined in a config and updated on an env basis.

    E.g.

    const trustedCa = [
        '/etc/pki/tls/certs/ca-bundle.crt',
        '/path/to/custom/cert.crt'
    ];
    
    https.globalAgent.options.ca = [];
    for (const ca of trustedCa) {
        https.globalAgent.options.ca.push(fs.readFileSync(ca));
    }
  24. TomasHubelbauer commented on Oct 5, 2021

    @TomasHubelbauer

    Can anyone please explain something I'm not understanding about the rationale of bundling own CA store in Node as opposed to using the system CA store?

    I see two reasons why Node might choose to use the Firefox's store:

    • Not have to interface with individual OS's APIs for trust stores
    • Be able to boot bad CAs in response to security-related events

    I think Mozilla's reason for bundling the CA store is primarily the latter as described in this article: https://blog.mozilla.org/security/2019/02/14/why-does-mozilla-maintain-our-own-root-certificate-store

    But, I do not think this applies to Node? Because since the store is bundled and Node doesn't not have a self-updater, no CA can be booted from an existing Node installation, correct? So if there was a bad CA to be removed, the Node installation at a user's server would have to be updated to the new version that removes the bad CA by updating the bundled store.

    If that is the case, is the situation merely that Node bundles the Mozilla CA store so that it doesn't have to implement each OS's APIs for the trust store reading? And since --use-openssl-ca is supported, is that not kind of a moot point now? Could --use-openssl-ca be made the default? What would the downsides of that be? Is it not the default due to backcompat concerns?

    Very curious to learn more about this, thank you in advance.

  25. ustun commented on Jan 15, 2022

    @ustun

    since --use-openssl-ca is supported, is that not kind of a moot point now?

    @TomasHubelbauer --use-openssl-ca is not supported on Windows since Windows has its own certificate store. But it might be made default elsewhere perhaps.

  26. Silcorrea78 commented on Jul 15, 2025

    @Silcorrea78

    Thank you for sharing don't feel dumb found you can not know everything.

  27. thoughtsunificator commented on Aug 17, 2025

    @thoughtsunificator

    This is terrible and should be addressed, NOT closed. Why is --use-openssl-ca still not the default? What is the rationale behind hard-coding vs system compliance.

    Also: Stop asking people to put effort and time into patches when the first step is to address the WHY and HOW this came to be, you cannot just rewrite entire software and then having your "patch" rejected because it looks cool.

  28. ustun-rn commented on Aug 18, 2025

    @ustun-rn

    For macOS and Windows, node recently added --use-system-ca flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    tlsIssues and PRs related to the tls subsystem.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions