Skip to content
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

ceremony/issuance: Remove PolicyIdentifiers extension and default to Policies #7969

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
6 changes: 3 additions & 3 deletions cmd/ceremony/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/ceremony/cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
22 changes: 11 additions & 11 deletions cmd/cert-checker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
mrand "math/rand/v2"
"os"
"slices"
"sort"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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
Expand Down
12 changes: 11 additions & 1 deletion issuance/cert.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,24 @@ 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,
OCSPServer: []string{i.ocspURL},
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
Expand Down
3 changes: 1 addition & 2 deletions issuance/cert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"crypto/rsa"
"crypto/x509"
"crypto/x509/pkix"
"encoding/asn1"
"encoding/base64"
"testing"
"time"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion linter/linter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading