Skip to content

Commit

Permalink
Merge branch 'main' into issuance-crls
Browse files Browse the repository at this point in the history
  • Loading branch information
aarongable authored Feb 9, 2024
2 parents 3c6acad + aece244 commit 89861bd
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 106 deletions.
11 changes: 6 additions & 5 deletions ca/ca_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ var (
const arbitraryRegID int64 = 1001

// Useful key and certificate files.
const caKeyFile = "../test/test-ca.key"
const caCertFile = "../test/test-ca.pem"
const caCertFile2 = "../test/test-ca2.pem"
const rsaIntKey = "../test/hierarchy/int-r3.key.pem"
const rsaIntCert = "../test/hierarchy/int-r3.cert.pem"
const ecdsaIntKey = "../test/hierarchy/int-e1.key.pem"
const ecdsaIntCert = "../test/hierarchy/int-e1.cert.pem"

func mustRead(path string) []byte {
return must.Do(os.ReadFile(path))
Expand Down Expand Up @@ -185,7 +186,7 @@ func setup(t *testing.T) *testCtx {
IssuerURL: "http://not-example.com/issuer-url",
OCSPURL: "http://not-example.com/ocsp",
CRLURLBase: "http://not-example.com/crl/",
Location: issuance.IssuerLoc{File: caKeyFile, CertFile: caCertFile2},
Location: issuance.IssuerLoc{File: ecdsaIntKey, CertFile: ecdsaIntCert},
}, fc)
test.AssertNotError(t, err, "Couldn't load test issuer")

Expand All @@ -195,7 +196,7 @@ func setup(t *testing.T) *testCtx {
IssuerURL: "http://not-example.com/issuer-url",
OCSPURL: "http://not-example.com/ocsp",
CRLURLBase: "http://not-example.com/crl/",
Location: issuance.IssuerLoc{File: caKeyFile, CertFile: caCertFile},
Location: issuance.IssuerLoc{File: rsaIntKey, CertFile: rsaIntCert},
}, fc)
test.AssertNotError(t, err, "Couldn't load test issuer")

Expand Down
8 changes: 6 additions & 2 deletions ca/ocsp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func TestOCSP(t *testing.T) {
test.AssertNotError(t, err, "Failed to create CA")
ocspi := testCtx.ocsp

// Issue a certificate from the RSA issuer caCert, then check OCSP comes from the same issuer.
// Issue a certificate from the RSA issuer, then check OCSP comes from that same issuer.
rsaIssuerID := ca.issuers.byAlg[x509.RSA].NameID()
rsaCertPB, err := ca.IssuePrecertificate(ctx, &capb.IssueCertificateRequest{Csr: CNandSANCSR, RegistrationID: arbitraryRegID})
test.AssertNotError(t, err, "Failed to issue certificate")
Expand All @@ -68,7 +68,11 @@ func TestOCSP(t *testing.T) {
test.AssertEquals(t, rsaOCSP.RevocationReason, 0)
test.AssertEquals(t, rsaOCSP.SerialNumber.Cmp(rsaCert.SerialNumber), 0)

// Issue a certificate from the ECDSA issuer caCert2, then check OCSP comes from the same issuer.
// Check that a different issuer cannot validate the OCSP response
_, err = ocsp.ParseResponse(rsaOCSPPB.Response, testCtx.boulderIssuers[0].Cert.Certificate)
test.AssertError(t, err, "Parsed / validated OCSP for rsaCert, but should not have")

// Issue a certificate from an ECDSA issuer, then check OCSP comes from that same issuer.
ecdsaIssuerID := ca.issuers.byAlg[x509.ECDSA].NameID()
ecdsaCertPB, err := ca.IssuePrecertificate(ctx, &capb.IssueCertificateRequest{Csr: ECDSACSR, RegistrationID: arbitraryRegID})
test.AssertNotError(t, err, "Failed to issue certificate")
Expand Down
6 changes: 3 additions & 3 deletions core/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -276,13 +276,13 @@ func TestLoadCert(t *testing.T) {
test.AssertError(t, err, "Loading non-PEM file did not error")
test.AssertEquals(t, err.Error(), "no data in cert PEM file \"../test/test-ca.der\"")

_, err = LoadCert("../test/test-ca.key")
_, err = LoadCert("../test/hierarchy/int-e1.key.pem")
test.AssertError(t, err, "Loading non-cert file did not error")
test.AssertEquals(t, err.Error(), "x509: malformed tbs certificate")

cert, err := LoadCert("../test/test-ca.pem")
cert, err := LoadCert("../test/hierarchy/int-r3.cert.pem")
test.AssertNotError(t, err, "Failed to load cert file")
test.AssertEquals(t, cert.Subject.CommonName, "happy hacker fake CA")
test.AssertEquals(t, cert.Subject.CommonName, "(TEST) Radical Rhino R3")
}

func TestRetryBackoff(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions test/config/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"issuerURL": "http://127.0.0.1:4001/aia/issuer/6605440498369741",
"ocspURL": "http://127.0.0.1:4002/",
"location": {
"configFile": "test/test-ca.key-pkcs11.json",
"configFile": "/hierarchy/intermediate-signing-key-rsa.pkcs11.json",
"certFile": "/hierarchy/intermediate-cert-rsa-a.pem",
"numSessions": 2
}
Expand All @@ -86,7 +86,7 @@
"issuerURL": "http://127.0.0.1:4001/aia/issuer/41127673797486028",
"ocspURL": "http://127.0.0.1:4002/",
"location": {
"configFile": "test/test-ca.key-pkcs11.json",
"configFile": "/hierarchy/intermediate-signing-key-rsa.pkcs11.json",
"certFile": "/hierarchy/intermediate-cert-rsa-b.pem",
"numSessions": 2
}
Expand Down
4 changes: 3 additions & 1 deletion test/example-blocked-keys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ blocked:
- cuwGhNNI6nfob5aqY90e7BleU6l7rfxku4X3UTJ3Z7M=
# test/block-a-key/test/test.rsa.jwk.json
- Qebc1V3SkX3izkYRGNJilm9Bcuvf0oox4U2Rn+b4JOE=
# test/hierarchy/int-r4.cert.pem
- +//lPMatuGvtf7yesXNv6FSf0UovKbP3BKdQZ23L4BY=
blockedHashesHex:
- 41e6dcd55dd2917de2ce461118d262966f4172ebdfd28a31e14d919fe6f824e1


28 changes: 0 additions & 28 deletions test/test-ca.key

This file was deleted.

5 changes: 0 additions & 5 deletions test/test-ca.key-pkcs11.json

This file was deleted.

27 changes: 0 additions & 27 deletions test/test-ca.pem

This file was deleted.

25 changes: 0 additions & 25 deletions test/test-ca2.pem

This file was deleted.

6 changes: 0 additions & 6 deletions test/test-root.key-pkcs11.json

This file was deleted.

4 changes: 2 additions & 2 deletions test/v2_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -1351,7 +1351,7 @@ def test_blocked_key_account():
if not CONFIG_NEXT:
return

with open("test/test-ca.key", "rb") as key_file:
with open("test/hierarchy/int-r4.key.pem", "rb") as key_file:
key = serialization.load_pem_private_key(key_file.read(), password=None, backend=default_backend())

# Create a client with the JWK set to a blocked private key
Expand Down Expand Up @@ -1379,7 +1379,7 @@ def test_blocked_key_cert():
if not CONFIG_NEXT:
return

with open("test/test-ca.key", "r") as f:
with open("test/hierarchy/int-r4.key.pem", "r") as f:
pemBytes = f.read()

domains = [random_domain(), random_domain()]
Expand Down

0 comments on commit 89861bd

Please sign in to comment.