-
Notifications
You must be signed in to change notification settings - Fork 0
fix: default readonly trust to mozilla and fix export csr subjects #195
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
Changes from all commits
a0db6a5
c3b60f3
1653a80
0d2bd09
57e4342
a582e21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -347,6 +347,7 @@ type CheckTrustAnchorsInput struct { | |||
| Cert *x509.Certificate | ||||
| Intermediates *x509.CertPool | ||||
| FileRoots *x509.CertPool | ||||
| TrustStore string | ||||
| } | ||||
|
|
||||
| // CheckTrustAnchorsResult reports which trust sources validated a certificate | ||||
|
|
@@ -410,35 +411,55 @@ func verifyChainTrustChains(input VerifyChainTrustInput) ([][]*x509.Certificate, | |||
| } | ||||
|
|
||||
| // CheckTrustAnchors reports which trust sources validate the certificate. | ||||
| // Results are returned in stable order: mozilla, system, file. | ||||
| // Results are returned in stable order: selected trust store, then file. | ||||
| func CheckTrustAnchors(input CheckTrustAnchorsInput) CheckTrustAnchorsResult { | ||||
| if input.Cert == nil { | ||||
| return CheckTrustAnchorsResult{Anchors: []string{}, Warnings: []string{}} | ||||
| } | ||||
|
|
||||
| result := CheckTrustAnchorsResult{ | ||||
| Anchors: make([]string, 0, 3), | ||||
| Anchors: make([]string, 0, 2), | ||||
| Warnings: make([]string, 0, 2), | ||||
| } | ||||
| if mozillaPool, err := MozillaRootPool(); err != nil { | ||||
| result.Warnings = append(result.Warnings, fmt.Sprintf("mozilla trust source unavailable: %v", err)) | ||||
| } else if VerifyChainTrust(VerifyChainTrustInput{ | ||||
| Cert: input.Cert, | ||||
| Roots: mozillaPool, | ||||
| Intermediates: input.Intermediates, | ||||
| TrustStore: "mozilla", | ||||
| }) { | ||||
| result.Anchors = append(result.Anchors, "mozilla") | ||||
| checkRoots := func(name string, roots *x509.CertPool) { | ||||
| if VerifyChainTrust(VerifyChainTrustInput{ | ||||
| Cert: input.Cert, | ||||
| Roots: roots, | ||||
| Intermediates: input.Intermediates, | ||||
| TrustStore: name, | ||||
| }) { | ||||
| result.Anchors = append(result.Anchors, name) | ||||
| } | ||||
| } | ||||
| if systemPool, err := SystemCertPoolCached(); err != nil { | ||||
| result.Warnings = append(result.Warnings, fmt.Sprintf("system trust source unavailable: %v", err)) | ||||
| } else if VerifyChainTrust(VerifyChainTrustInput{ | ||||
| Cert: input.Cert, | ||||
| Roots: systemPool, | ||||
| Intermediates: input.Intermediates, | ||||
| TrustStore: "system", | ||||
| }) { | ||||
| result.Anchors = append(result.Anchors, "system") | ||||
|
|
||||
| trustStore := input.TrustStore | ||||
| if trustStore == "" { | ||||
| trustStore = "mozilla" | ||||
| } | ||||
| switch trustStore { | ||||
| case "mozilla": | ||||
| mozillaPool, err := MozillaRootPool() | ||||
| if err != nil { | ||||
| result.Warnings = append(result.Warnings, fmt.Sprintf("mozilla trust source unavailable: %v", err)) | ||||
| break | ||||
| } | ||||
| checkRoots("mozilla", mozillaPool) | ||||
| case "system": | ||||
| systemPool, err := SystemCertPoolCached() | ||||
| if err != nil { | ||||
| result.Warnings = append(result.Warnings, fmt.Sprintf("system trust source unavailable: %v", err)) | ||||
| break | ||||
| } | ||||
| checkRoots("system", systemPool) | ||||
| case "custom": | ||||
| result.Warnings = append(result.Warnings, "custom trust store cannot be evaluated without an explicit roots pool") | ||||
| case "file": | ||||
| if input.FileRoots == nil { | ||||
| result.Warnings = append(result.Warnings, "file trust store cannot be evaluated without file roots") | ||||
| } | ||||
| default: | ||||
| result.Warnings = append(result.Warnings, fmt.Sprintf("unsupported trust store %q", trustStore)) | ||||
| return result | ||||
|
||||
| return result |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When
CheckTrustAnchorsis called withTrustStore: "custom"and a non-nilFileRootspool (for example viaVerifyCertwith custom roots), this branch always adds the warning that no explicit roots pool was provided. The same call can still append"file"totrust_anchors, so output becomes self-contradictory (trust_anchorsshows success whiletrust_warningsclaims roots are missing), which can trigger false failures in warning-sensitive tooling.Useful? React with 👍 / 👎.