Skip to content

crypto/x509: support SSL_CERT_FILE/DIR on Darwin and Windows #77865

Closed

Description

@rolandshoemaker

On darwin systems we use the platform certificate verifier, instead of the native Go one, by default. The only time we don't do this is if GODEBUG=x509usefallbackroots=1 is set and x509.SetFallbackRoots has been called.

Using the system verifier relies on a program being able to access the trustd service (via the darwin APIs we call), which is a daemon which does all of the certificate verification work for us.

There are some scenarios where someone running a Go program may want to limit access to trustd (e.g. see anthropics/sandbox-runtime#118). In this scenario, the program cannot be directly mutated to change the verifier settings (e.g. by using x509.SetFallbackRoots) and may wish to choose which roots to trust using SSL_CERT_FILE.

Currently, we explicitly do not support SSL_CERT_FILE on darwin, and only support it on non-darwin unix's.

It may be reasonable to support this use-case, by falling back to the native Go verifier if SSL_CERT_FILE is set on darwin system.

This could cause breakage, as we explicitly document that SSL_CERT_FILE is not used on darwin systems by Go, but is used by other programs in the environment and is set. Adding support for SSL_CERT_FILE would thus result in a change in program behavior, as we would no longer use the platform verifier.

This could be remedied by introducing a new GODEBUG that tells the program to either use the value of SSL_CERT_FILE or ignore it (e.g. maintaining our existing behavior).

cc @golang/security @rsc

Activity

  1. added
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Feb 28, 2026
  2. added this to the Proposal milestone on Feb 28, 2026
  3. removed
    NeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.
    on Feb 28, 2026
  4. added
    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a tool
    on Feb 28, 2026
  5. FiloSottile commented on Feb 28, 2026

    @FiloSottile
    Contributor

    I think this is a subset of #71924.

  6. rsc commented on Apr 21, 2026

    @rsc
    Contributor

    If #71924 wants to contemplate broader things that's fine, but the industry has standardized on SSL_CERT_FILE, and we should support that.

  7. aclements commented on Apr 22, 2026

    @aclements
    Member

    Proposal review discussion:

    • We already support SSL_CERT_FILE and SSL_CERT_DIR on all of the Unixes except Darwin.
    • If we support SSL_CERT_FILE, we should probably support SSL_CERT_DIR, too (unfortunately)
    • The main drawback of this is that we currently document that we ignore SSL_CERT_FILE on Darwin. We'd add GODEBUG=x509sslcertoverrideplatform. It would default to 1, but could be set to 0 to revert to the current behavior on Darwin. On Linux, the platform verifier itself uses SSL_CERT_FILE, so this variable has no effect either way.
  8. moved this to Active in Proposalson Apr 22, 2026
  9. aclements commented on Apr 22, 2026

    @aclements
    Member

    This proposal has been added to the active column of the proposals project
    and will now be reviewed at the weekly proposal review meetings.
    — aclements for the proposal review group

  10. connorshea commented on Apr 26, 2026

    @connorshea

    Speaking only as a user of Go binaries like gh and glab, not the Go language itself, this'd be a welcome change as it's the only significant problem I've run into while sandboxing my Claude Code instance :) The setting workaround in Claude Code is fine for now, but this'd be great to have fixed properly in Go itself. 🙇

  11. aclements commented on Apr 29, 2026

    @aclements
    Member

    Here's the proposal as I understand it:

    Enable support for SSL_CERT_FILE and SSL_CERT_DIR on Darwin, matching all other Unixes. If either is set, the Go library bypasses the platform verifier.

    Add a GODEBUG called x509sslcertoverrideplatform, defaulting to 1. If set to 0 on Darwin, we would ignore SSL_CERT_FILE and SSL_CERT_DIR (reverting to pre-Go 1.27 behavior). On Linux, the platform verifier itself uses SSL_CERT_FILE, so this variable has no effect either way.

    Question:

    If building with a pre-Go 1.27 language version, should x509sslcertoverrideplatform default to 0 (old/compatible behavior)?

  12. 12 remaining items

  13. gopherbot commented on May 11, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/776940 mentions this issue: crypto/x509: honor SSL_CERT_{FILE,DIR} on windows/darwin

  14. aclements commented on May 13, 2026

    @aclements
    Member

    No change in consensus, so accepted. 🎉
    This issue now tracks the work of implementing the proposal.
    — aclements for the proposal review group

    The proposal is to support SSL_CERT_FILE and SSL_CERT_DIR on Darwin and Windows, as we do on all non-Darwin Unix platforms already. When set, the platform verifier is not used, and the native Go verifier is used instead with the roots found in the relevant file or directory

    For compatibility, we will add a GODEBUG called x509sslcertoverrideplatform to control this behavior. It will default to 1 with language version Go 1.27+ and 0 with previous language versions. If set to 0 on Darwin or Windows, we would ignore SSL_CERT_FILE and SSL_CERT_DIR (reverting to pre-Go 1.27 behavior). On other Unixes, the verifier always uses SSL_CERT_FILE, so this variable has no effect either way.

  15. moved this from Likely Accept to Accepted in Proposalson May 13, 2026
  16. changed the title [-]proposal: crypto/x509: support SSL_CERT_FILE/DIR on Darwin and Windows[/-] [+]crypto/x509: support SSL_CERT_FILE/DIR on Darwin and Windows[/+] on May 13, 2026
  17. modified the milestones: Proposal, Backlog on May 13, 2026
  18. added a commit that references this issue on May 19, 2026
    4bf23b5
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

    LibraryProposalIssues describing a requested change to the Go standard library or x/ libraries, but not to a toolOS-DarwinProposalProposal-Accepted

    Type

    No type

    Projects

    • Status
      Accepted

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions