-
Notifications
You must be signed in to change notification settings - Fork 18k
crypto/x509: parse macOS keychain policies instead of using verify-cert #24084
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
Comments
I talked with @agl and he suggested we could look into attaching the extracted policies onto each certificate and then check those in Verify. A certificate with
kSecTrustSettingsPolicyName looks to be a set of magic strings. |
I've got the https://github.com/adamdecaf/plist-parser/blob/9606801b8fea0e91cf12d7e5c66cf30e937e2867/main.go#L84 I think with this parsing we could get rid of type trustPolicy struct {
name string // kSecTrustSettingsPolicyName values (e.g. basicX509, sslServer, CodeSigning)
result string // kSecTrustSettingsResult
} |
Change https://golang.org/cl/98336 mentions this issue: |
Putting this on @FiloSottile's radar just in case he hasn't yet seen it or might be interested in it :) |
This seems like the right path, but too late to change in 1.11. It should also probably try to reuse some logic from the cgo path. |
Change https://golang.org/cl/121356 mentions this issue: |
Change https://golang.org/cl/121357 mentions this issue: |
Now that pkix.Name offers String() we should use that as some CN's are blank. Updates #24084 Change-Id: I268196f04b98c2bd4d5d0cf1fecd2c9bafeec0f1 Reviewed-on: https://go-review.googlesource.com/121357 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
https://go-review.googlesource.com/c/go/+/128116 checks with a trust policy. Closing. (See #24652 also) |
On Darwin systems there's a non-cgo path using the provided
security
cli tool for gathering certificates to use. (e.g.x509.SystemCertPool()
) The current code callssecurity verify-cert
which searches keychains on the filesystem for policies related to the certificate in an attempt to respect trust settings applied.One can apply a trust setting that would disable "ssl", but Go currently doesn't parse that out of the keychain.
The problem is that
security verify-cert
doesn't returnkSecTrustSettingsResultDeny
if the certificate is only denied for ssl. The flag-p
is defaulted tobasic
(instead of sayssl
orcodeSign
).This can be verified with the following patch in
src/crypto/x509/root_darwin.go
.This doesn't solve the problem outside of TLS though. There are multiple policies which can be applied to selectively disable certificates for. The trust policies are better stated in the output of
security trust-settings-export
, which is already called, but the response not fully parsed.The text was updated successfully, but these errors were encountered: