diff --git a/Makefile b/Makefile index 9522b89a72f..94d8167ac06 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ $(CMD_BINS): build_cmds build_cmds: | $(OBJDIR) echo $(OBJECTS) - GOBIN=$(OBJDIR) GO111MODULE=on go install -mod=vendor $(GO_BUILD_FLAGS) ./... + GOBIN=$(OBJDIR) GO111MODULE=on GODEBUG=x509usepolicies=1 go install -mod=vendor $(GO_BUILD_FLAGS) ./... # Building a .deb requires `fpm` from https://github.com/jordansissel/fpm # which you can install with `gem install fpm`. diff --git a/cmd/ceremony/cert.go b/cmd/ceremony/cert.go index 7f3893593e2..d0da70f372f 100644 --- a/cmd/ceremony/cert.go +++ b/cmd/ceremony/cert.go @@ -318,11 +318,11 @@ func makeTemplate(randReader io.Reader, profile *certProfile, pubKey []byte, tbc } for _, policyConfig := range profile.Policies { - oid, err := parseOID(policyConfig.OID) + x509OID, err := x509.ParseOID(policyConfig.OID) if err != nil { - return nil, err + return nil, fmt.Errorf("failed to parse %s as OID: %w", policyConfig.OID, err) } - cert.PolicyIdentifiers = append(cert.PolicyIdentifiers, oid) + cert.Policies = append(cert.Policies, x509OID) } return cert, nil diff --git a/cmd/ceremony/cert_test.go b/cmd/ceremony/cert_test.go index 95a2b33755f..c67e8ec455a 100644 --- a/cmd/ceremony/cert_test.go +++ b/cmd/ceremony/cert_test.go @@ -126,7 +126,7 @@ func TestMakeTemplateRoot(t *testing.T) { test.AssertEquals(t, len(cert.IssuingCertificateURL), 1) test.AssertEquals(t, cert.IssuingCertificateURL[0], profile.IssuerURL) test.AssertEquals(t, cert.KeyUsage, x509.KeyUsageDigitalSignature|x509.KeyUsageCRLSign) - test.AssertEquals(t, len(cert.PolicyIdentifiers), 2) + test.AssertEquals(t, len(cert.Policies), 2) test.AssertEquals(t, len(cert.ExtKeyUsage), 0) cert, err = makeTemplate(randReader, profile, pubKey, nil, intermediateCert) diff --git a/cmd/cert-checker/main_test.go b/cmd/cert-checker/main_test.go index 137b05767e2..493637fea45 100644 --- a/cmd/cert-checker/main_test.go +++ b/cmd/cert-checker/main_test.go @@ -18,7 +18,6 @@ import ( mrand "math/rand/v2" "os" "slices" - "sort" "strings" "sync" "testing" @@ -585,18 +584,19 @@ func TestIgnoredLint(t *testing.T) { checker := newChecker(saDbMap, clock.NewFake(), pa, kp, time.Hour, testValidityDurations, blog.NewMock()) serial := big.NewInt(1337) + x509OID, err := x509.OIDFromInts([]uint64{1, 2, 3}) + test.AssertNotError(t, err, "failed to create x509.OID") + template := &x509.Certificate{ Subject: pkix.Name{ CommonName: "CPU's Cool CA", }, - SerialNumber: serial, - NotBefore: time.Now(), - NotAfter: time.Now().Add(testValidityDuration - time.Second), - KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, - ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, - PolicyIdentifiers: []asn1.ObjectIdentifier{ - {1, 2, 3}, - }, + SerialNumber: serial, + NotBefore: time.Now(), + NotAfter: time.Now().Add(testValidityDuration - time.Second), + KeyUsage: x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign, + ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth}, + Policies: []x509.OID{x509OID}, BasicConstraintsValid: true, IsCA: true, IssuingCertificateURL: []string{"http://aia.example.org"}, @@ -639,12 +639,12 @@ func TestIgnoredLint(t *testing.T) { "zlint info: w_ct_sct_policy_count_unsatisfied Certificate had 0 embedded SCTs. Browser policy may require 2 for this certificate.", "zlint error: e_scts_from_same_operator Certificate had too few embedded SCTs; browser policy requires 2.", } - sort.Strings(expectedProblems) + slices.Sort(expectedProblems) // Check the certificate with a nil ignore map. This should return the // expected zlint problems. _, problems := checker.checkCert(context.Background(), cert, nil) - sort.Strings(problems) + slices.Sort(problems) test.AssertDeepEquals(t, problems, expectedProblems) // Check the certificate again with an ignore map that excludes the affected diff --git a/issuance/cert.go b/issuance/cert.go index 0c97b1b84c5..9999d3b9bcf 100644 --- a/issuance/cert.go +++ b/issuance/cert.go @@ -192,6 +192,16 @@ func (i *Issuer) requestValid(clk clock.Clock, prof *Profile, req *IssuanceReque return nil } +// Baseline Requirements, Section 7.1.6.1: domain-validated +var domainValidatedOID = func() x509.OID { + x509OID, err := x509.OIDFromInts([]uint64{2, 23, 140, 1, 2, 1}) + if err != nil { + // This should never happen, as the OID is hardcoded. + panic(fmt.Errorf("failed to create OID using ints %v: %s", x509OID, err)) + } + return x509OID +}() + func (i *Issuer) generateTemplate() *x509.Certificate { template := &x509.Certificate{ SignatureAlgorithm: i.sigAlg, @@ -199,7 +209,7 @@ func (i *Issuer) generateTemplate() *x509.Certificate { IssuingCertificateURL: []string{i.issuerURL}, BasicConstraintsValid: true, // Baseline Requirements, Section 7.1.6.1: domain-validated - PolicyIdentifiers: []asn1.ObjectIdentifier{{2, 23, 140, 1, 2, 1}}, + Policies: []x509.OID{domainValidatedOID}, } // TODO(#7294): Use i.crlURLBase and a shard calculation to create a diff --git a/issuance/cert_test.go b/issuance/cert_test.go index 80f8c5d4674..a6e7bfc57d4 100644 --- a/issuance/cert_test.go +++ b/issuance/cert_test.go @@ -9,7 +9,6 @@ import ( "crypto/rsa" "crypto/x509" "crypto/x509/pkix" - "encoding/asn1" "encoding/base64" "testing" "time" @@ -321,7 +320,7 @@ func TestGenerateTemplate(t *testing.T) { IssuingCertificateURL: []string{"http://issuer"}, OCSPServer: []string{"http://ocsp"}, CRLDistributionPoints: nil, - PolicyIdentifiers: []asn1.ObjectIdentifier{{2, 23, 140, 1, 2, 1}}, + Policies: []x509.OID{domainValidatedOID}, } test.AssertDeepEquals(t, actual, expected) diff --git a/linter/linter.go b/linter/linter.go index e9bf33b85a2..522dd5ee5a6 100644 --- a/linter/linter.go +++ b/linter/linter.go @@ -194,7 +194,7 @@ func makeIssuer(realIssuer *x509.Certificate, lintSigner crypto.Signer) (*x509.C PermittedEmailAddresses: realIssuer.PermittedEmailAddresses, PermittedIPRanges: realIssuer.PermittedIPRanges, PermittedURIDomains: realIssuer.PermittedURIDomains, - PolicyIdentifiers: realIssuer.PolicyIdentifiers, + Policies: realIssuer.Policies, SerialNumber: realIssuer.SerialNumber, Subject: realIssuer.Subject, SubjectKeyId: realIssuer.SubjectKeyId,