crypto/x509: if system keychain has a cert with an empty but valid trust settings array, cert should be trusted but Go does not trust it #27958
Labels
FrozenDueToAge
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
OS-Darwin
Security
Milestone
The OS X-specific code for finding system trusted roots has a bug. The code that is assessing each certificate configured in the keychain defaults all flags to zero here. Later, if the resulting trust settings array is empty, the code will fail to change any of the flags, here. If they are all unset, it ends up putting the cert into the "untrusted" section here.
However, in the Apple documentation, it explicitly states that if a given trust settings array is valid but empty, that it means "always trust this cert":
https://developer.apple.com/documentation/security/1400261-sectrustsettingscopytrustsetting?language=objc#discussion
The fix is to simply set
trustRoot = 1;
if the array is empty.What version of Go are you using (
go version
)?go version go1.10.4 darwin/amd64
Does this issue reproduce with the latest release?
I have not tried. However, I tracked down the source of the bug in the runtime source, and that portion of the runtime is unchanged in latest. (So I am pretty certain it will still repro in latest.)
What operating system and processor architecture are you using (
go env
)?What did you do?
Added a self-signed cert as a trusted root to the system keychain:
I use that cert in a Go HTTP server. Here is a simple example:
Now I use
/etc/hosts
to make sure thatwww.local.test
resolves to my loopback interface:When I run a simple Go client program, even though my browser trusts the cert due to configuration above, Go does not:
What did you expect to see?
I expected the client program to trust the server's cert (since browsers and other system functions do). That means the client program should have trivially succeeded.
What did you see instead?
Output of test Go client program:
The text was updated successfully, but these errors were encountered: