-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
crypto/x509: Trust relationship of certs returned by 'x509.SystemCertPool()' is ambiguous #39540
Comments
Yeah, SystemCertPool needs to be cleaned up and documented, but given we had major changes to crypto/x509 in Go 1.15 I'd like to give it a rest in Go 1.16, so targeting Go 1.17. |
Do we still expect to address this for 1.17? Thanks. |
FWIW: Red Hat's documentation describes the Shared System Certificates mechanism like this:
I.e. this is what I would consider the "SystemCertPool" of Red Hat/CentOS. (btw: I agreed this name is not optimal.) It works like this: You can place additional CA certs in anchor/blacklist cert directories (see the link for details) and then execute To quote the update-ca-trust(8) man page:
Thus, from my understanding, if Actually, Go already does this via the ^1: Of course, the (Note: There's also the generated file |
It seems this is a bigger issue (as mentioned in proposal #46287) that won't happen in time for Go 1.17 given we're 3 weeks into the release freeze, so moving to Backlog. Please update it as needed. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?CentOS 7.8.
go env
OutputWhat did you do?
On a CentOS 7.8 system, the
x509.SystemCertPool()
function returns aCertPool
containing all X.509 certificates stored in the directory/etc/pki/tls/certs/
. While I cannot find a clear source describing the purpose of this directory, there is RedHat documentation that indicates Apache httpd end entity (server) certificates can be stored there (I believe this is also the default directory for end entity certificates in the httpd configs as well). This can be seen in the following snippets from https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/5/html/deployment_guide/s1-httpd-secure-server:I would never implicitly trust these certificates, even if I am serving them. However, the
CertPool
returned bySystemCertPool()
includes them vialoadSystemRoots()
in 'root_unix.go'.Taking a look at the function, its current documentation states:
I realize that there is no mention of trust relationship here - however, in a few spots in the code, there are hints about "roots", which to me indicates CA certificates (or at least non-server certificates). For example the error message in 'cert_pool.go', line 50:
And the function name
loadSystemRoots()
, and the local variable name in 'root_unix.go', line 39:The change to search in
/etc/pki/tls/certs
for certificates inloadSystemRoots()
occurred in:e83bcd9
I do not see any obvious reason why any random certificate file in this directory would be trusted, barring
ca-bundle.crt
. As noted in the RedHat documentation, there could be end entity certificates stored in/etc/pki/tls/certs
... So, Go's behavior feels incorrect.At the very least, the purpose of
SystemCertPool()
feels ambiguous.What did you expect to see?
I expected
x509.SystemCertPool()
to return only CA certificates trusted by the operating system.What did you see instead?
The function returns non-CA, or end entity certificates that are not trusted by the operating system (specifically, on CentOS 7.8). This can result in unexpected validation paths ("verified chains" as referenced by the Go library) when connecting to TLS servers.
The text was updated successfully, but these errors were encountered: