CA: Fail construction if no issuers are provided (#6736)

If a CA config is created with an empty `issuers[]` json, then the CA
should fail to start up. With no issuers present, the integration tests
fail with the following error truncated for readability.
```
boulder-ra [AUDIT] Certificate request - error 
Error":"issuing precertificate: no issuer found for public key algorithm RSA"
```

Fixes https://github.com/letsencrypt/boulder/issues/6735
This commit is contained in:
Phil Porada 2023-03-09 18:34:38 -05:00 committed by GitHub
parent 88569e618b
commit b9f0fe030a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 29 additions and 0 deletions

View File

@ -131,6 +131,10 @@ func NewCertificateAuthorityImpl(
return nil, err
}
if len(boulderIssuers) == 0 {
return nil, errors.New("must have at least one issuer")
}
issuers := makeIssuerMaps(boulderIssuers)
orphanCount := prometheus.NewCounterVec(

View File

@ -421,6 +421,31 @@ func issueCertificateSubTestValidityUsesCAClock(t *testing.T, i *TestCertificate
test.AssertEquals(t, i.cert.NotAfter.Add(time.Second).Sub(i.cert.NotBefore), i.ca.validityPeriod)
}
// Test failure mode when no issuers are present.
func TestNoIssuers(t *testing.T) {
testCtx := setup(t)
sa := &mockSA{}
_, err := NewCertificateAuthorityImpl(
sa,
testCtx.pa,
testCtx.ocsp,
nil, // No issuers
nil,
testCtx.certExpiry,
testCtx.certBackdate,
testCtx.serialPrefix,
testCtx.maxNames,
testCtx.keyPolicy,
nil,
testCtx.logger,
testCtx.stats,
testCtx.signatureCount,
testCtx.signErrorCount,
testCtx.fc)
test.AssertError(t, err, "No issuers found during CA construction.")
test.AssertEquals(t, err.Error(), "must have at least one issuer")
}
// Test issuing when multiple issuers are present.
func TestMultipleIssuers(t *testing.T) {
testCtx := setup(t)