Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std.crypto.Certificate.Bundle/macos: rescanMac picks non-default keychain to pull certificates from #21106

Open
cixel opened this issue Aug 17, 2024 · 0 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-macos standard library This issue involves writing Zig code for the standard library.
Milestone

Comments

@cixel
Copy link

cixel commented Aug 17, 2024

Zig Version

0.13.0

Steps to Reproduce and Observed Behavior

rescanMac populates the system cert pool by reading from the keychain at /System/Library/Keychains/SystemRootCertificates.keychain. When I query my system's keychains, this isn't listed:

$ /usr/bin/security list-keychains
    "~/Library/Keychains/login.keychain-db"
    "/Library/Keychains/System.keychain"

$ /usr/bin/security default-keychain
    "~/Library/Keychains/login.keychain-db"

This causes problems on my work computer, which sits behind an SSL-intercepting proxy. I believe the proxy installed its root CA to one of these keychains, but not to the one which is hardcoded in rescanMac, which leads to TlsInitializationFailed errors for std.http.Client requests. This also means that zig build fails when fetching dependencies.

Expected Behavior

It's unclear to me whether "fault" here belongs to std.crypto.Certificate.Bundle for only checking on spot for the keychain, or to the proxy for installing its root CA to the keychain in /System.

Regardless, I think there are a couple of things that could be done:

  • either sub-process /usr/bin/security to query for which keychain(s) to use, or invoke Apple's Security.framework APIs directly
    • it might be necessary to dynamically load the APIs directly from e.g /System/Library/Frameworks/Security.framework/Versions/A/Security using std.DynLib?
  • it would be helpful to have a way to supply a cert bundle file with an env var, as in curl's CURL_CA_BUNDLE variable
@cixel cixel added the bug Observed behavior contradicts documented or intended behavior label Aug 17, 2024
@andrewrk andrewrk added standard library This issue involves writing Zig code for the standard library. os-macos labels Nov 1, 2024
@andrewrk andrewrk added this to the 0.16.0 milestone Nov 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-macos standard library This issue involves writing Zig code for the standard library.
Projects
None yet
Development

No branches or pull requests

2 participants