-
Notifications
You must be signed in to change notification settings - Fork 17.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
crypto/x509: fix certificate policy marshaling
CL 520535 added the new OID type, and the Certificate field Policies to replace PolicyIdentifiers. During review I missed three problems: (1) the marshaling of Certificate didn't take into account the case where both fields were populated with the same OIDs (which would be the case if you parsed a certificate and used it as a template), (2) buildCertExtensions only generated the certificate policies extension if PolicyIdentifiers was populated, and (3) how we would marshal an empty OID (i.e. OID{}). This change makes marshaling a certificate with an empty OID an error, and only adds a single copy of any OID that appears in both Policies and PolicyIdentifiers to the certificate policies extension. This should make the round trip behavior for certificates reasonable. Additionally this change documents that CreateCertificate uses the Policies field from the template, and fixes buildCertExtensions to populate the certificate policies extension if _either_ PolicyIdentifiers or Policies is populated, not just PolicyIdentifiers. Fixes #63909 Change-Id: I0fcbd3ceaab7a376e7e991ff8b37e2145ffb4a61 Reviewed-on: https://go-review.googlesource.com/c/go/+/539297 Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com> Reviewed-by: Damien Neil <dneil@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
- Loading branch information
1 parent
1764da7
commit e2d9574
Showing
2 changed files
with
37 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters