Skip to content

Commit d8a786e

Browse files
authored
Unify usage of 'issuer' and 'signer' as nouns (letsencrypt#5085)
We define a "signer" to be a private key, or something that satisfies the crypto.Signer interface. We define an "issuer" to be an object which has both a signer (so it can sign things) and a certificate (so that the things it signs can have appropriate issuer fields set). As a result, this change: - moves the new "signer" library to be called "issuance" instead - renames several "signers" to instead be "issuers", as defined above - renames several "issuers" to instead be "certs", to reduce confusion more There are some further cleanups which could be made, but most of them will be made irrelevant by the removal of the CFSSL code, so I'm leaving them be for now.
1 parent ad2ec78 commit d8a786e

File tree

6 files changed

+151
-150
lines changed

6 files changed

+151
-150
lines changed

ca/ca.go

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ import (
3939
berrors "github.com/letsencrypt/boulder/errors"
4040
"github.com/letsencrypt/boulder/features"
4141
"github.com/letsencrypt/boulder/goodkey"
42+
"github.com/letsencrypt/boulder/issuance"
4243
blog "github.com/letsencrypt/boulder/log"
4344
sapb "github.com/letsencrypt/boulder/sa/proto"
44-
bsigner "github.com/letsencrypt/boulder/signer"
4545
)
4646

4747
// Miscellaneous PKIX OIDs that we need to refer to
@@ -167,42 +167,42 @@ type internalIssuer struct {
167167
cert *x509.Certificate
168168
ocspSigner crypto.Signer
169169

170-
// Only one of cfsslSigner and boulderSigner will be non-nill
170+
// Only one of cfsslSigner and boulderIssuer will be non-nill
171171
cfsslSigner localSigner
172-
boulderSigner *bsigner.Signer
172+
boulderIssuer *issuance.Issuer
173173
}
174174

175-
func makeInternalIssuers(issuers []bsigner.Config, lifespanOCSP time.Duration) (issuerMaps, error) {
175+
func makeInternalIssuers(configs []issuance.IssuerConfig, lifespanOCSP time.Duration) (issuerMaps, error) {
176176
issuersByAlg := make(map[x509.PublicKeyAlgorithm]*internalIssuer, 2)
177-
issuersByName := make(map[string]*internalIssuer, len(issuers))
178-
issuersByID := make(map[int64]*internalIssuer, len(issuers))
179-
for _, issuer := range issuers {
180-
signer, err := bsigner.NewSigner(issuer)
177+
issuersByName := make(map[string]*internalIssuer, len(configs))
178+
issuersByID := make(map[int64]*internalIssuer, len(configs))
179+
for _, config := range configs {
180+
issuer, err := issuance.New(config)
181181
if err != nil {
182182
return issuerMaps{}, err
183183
}
184184
ii := &internalIssuer{
185-
cert: issuer.Issuer,
186-
ocspSigner: issuer.Signer,
187-
boulderSigner: signer,
185+
cert: config.Cert,
186+
ocspSigner: config.Signer,
187+
boulderIssuer: issuer,
188188
}
189-
if issuer.Profile.UseForRSALeaves {
189+
if config.Profile.UseForRSALeaves {
190190
if issuersByAlg[x509.RSA] != nil {
191191
return issuerMaps{}, errors.New("Multiple issuer certs for RSA are not allowed")
192192
}
193193
issuersByAlg[x509.RSA] = ii
194194
}
195-
if issuer.Profile.UseForECDSALeaves {
195+
if config.Profile.UseForECDSALeaves {
196196
if issuersByAlg[x509.ECDSA] != nil {
197197
return issuerMaps{}, errors.New("Multiple issuer certs for ECDSA are not allowed")
198198
}
199199
issuersByAlg[x509.ECDSA] = ii
200200
}
201-
if issuersByName[issuer.Issuer.Subject.CommonName] != nil {
201+
if issuersByName[config.Cert.Subject.CommonName] != nil {
202202
return issuerMaps{}, errors.New("Multiple issuer certs with the same CommonName are not supported")
203203
}
204-
issuersByName[issuer.Issuer.Subject.CommonName] = ii
205-
issuersByID[idForIssuer(issuer.Issuer)] = ii
204+
issuersByName[config.Cert.Subject.CommonName] = ii
205+
issuersByID[idForCert(config.Cert)] = ii
206206
}
207207
return issuerMaps{issuersByAlg, issuersByName, issuersByID}, nil
208208
}
@@ -245,15 +245,15 @@ func makeCFSSLInternalIssuers(issuers []Issuer, policy *cfsslConfig.Signing, lif
245245
issuersByAlg[x509.ECDSA] = ii
246246
}
247247
issuersByName[cn] = ii
248-
issuersByID[idForIssuer(iss.Cert)] = ii
248+
issuersByID[idForCert(iss.Cert)] = ii
249249
}
250250
return issuerMaps{issuersByAlg, issuersByName, issuersByID}, nil
251251
}
252252

253-
// idForIssuer generates a stable ID for an issuer certificate. This
253+
// idForCert generates a stable ID for an issuer certificate. This
254254
// is used for identifying which issuer issued a certificate in the
255255
// certificateStatus table.
256-
func idForIssuer(cert *x509.Certificate) int64 {
256+
func idForCert(cert *x509.Certificate) int64 {
257257
h := sha256.Sum256(cert.Raw)
258258
return big.NewInt(0).SetBytes(h[:4]).Int64()
259259
}
@@ -268,7 +268,7 @@ func NewCertificateAuthorityImpl(
268268
clk clock.Clock,
269269
stats prometheus.Registerer,
270270
cfsslIssuers []Issuer,
271-
boulderIssuers []bsigner.Config,
271+
boulderIssuers []issuance.IssuerConfig,
272272
keyPolicy goodkey.KeyPolicy,
273273
logger blog.Logger,
274274
orphanQueue *goque.Queue,
@@ -600,7 +600,7 @@ func (ca *CertificateAuthorityImpl) IssuePrecertificate(ctx context.Context, iss
600600
RegID: regID,
601601
Ocsp: ocspResp.Response,
602602
Issued: nowNanos,
603-
IssuerID: idForIssuer(issuer.cert),
603+
IssuerID: idForCert(issuer.cert),
604604
}
605605

606606
_, err = ca.sa.AddPrecertificate(ctx, req)
@@ -617,7 +617,7 @@ func (ca *CertificateAuthorityImpl) IssuePrecertificate(ctx context.Context, iss
617617
RegID: regID,
618618
OCSPResp: ocspResp.Response,
619619
Precert: true,
620-
IssuerID: idForIssuer(issuer.cert),
620+
IssuerID: idForCert(issuer.cert),
621621
})
622622
}
623623
return nil, err
@@ -686,11 +686,11 @@ func (ca *CertificateAuthorityImpl) IssueCertificateForPrecertificate(ctx contex
686686

687687
var certDER []byte
688688
if features.Enabled(features.NonCFSSLSigner) {
689-
issuanceReq, err := bsigner.RequestFromPrecert(precert, scts)
689+
issuanceReq, err := issuance.RequestFromPrecert(precert, scts)
690690
if err != nil {
691691
return nil, err
692692
}
693-
certDER, err = issuer.boulderSigner.Issue(issuanceReq)
693+
certDER, err = issuer.boulderIssuer.Issue(issuanceReq)
694694
if err != nil {
695695
return nil, err
696696
}
@@ -711,7 +711,7 @@ func (ca *CertificateAuthorityImpl) IssueCertificateForPrecertificate(ctx contex
711711
ca.log.AuditInfof("Signing success: serial=[%s] names=[%s] csr=[%s] certificate=[%s]",
712712
serialHex, strings.Join(precert.DNSNames, ", "), hex.EncodeToString(req.DER),
713713
hex.EncodeToString(certDER))
714-
err = ca.storeCertificate(ctx, req.RegistrationID, req.OrderID, precert.SerialNumber, certDER, idForIssuer(issuer.cert))
714+
err = ca.storeCertificate(ctx, req.RegistrationID, req.OrderID, precert.SerialNumber, certDER, idForCert(issuer.cert))
715715
if err != nil {
716716
return nil, err
717717
}
@@ -795,13 +795,13 @@ func (ca *CertificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
795795
if features.Enabled(features.NonCFSSLSigner) {
796796
ca.log.AuditInfof("Signing: serial=[%s] names=[%s] csr=[%s]",
797797
serialHex, strings.Join(csr.DNSNames, ", "), hex.EncodeToString(csr.Raw))
798-
certDER, err = issuer.boulderSigner.Issue(&bsigner.IssuanceRequest{
798+
certDER, err = issuer.boulderIssuer.Issue(&issuance.IssuanceRequest{
799799
PublicKey: csr.PublicKey,
800800
Serial: serialBigInt.Bytes(),
801801
CommonName: csr.Subject.CommonName,
802802
DNSNames: csr.DNSNames,
803803
IncludeCTPoison: true,
804-
IncludeMustStaple: bsigner.ContainsMustStaple(csr.Extensions),
804+
IncludeMustStaple: issuance.ContainsMustStaple(csr.Extensions),
805805
NotBefore: validity.NotBefore,
806806
NotAfter: validity.NotAfter,
807807
})

ca/ca_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,11 @@ import (
3838
berrors "github.com/letsencrypt/boulder/errors"
3939
"github.com/letsencrypt/boulder/features"
4040
"github.com/letsencrypt/boulder/goodkey"
41+
"github.com/letsencrypt/boulder/issuance"
4142
blog "github.com/letsencrypt/boulder/log"
4243
"github.com/letsencrypt/boulder/metrics"
4344
"github.com/letsencrypt/boulder/policy"
4445
sapb "github.com/letsencrypt/boulder/sa/proto"
45-
bsigner "github.com/letsencrypt/boulder/signer"
4646
"github.com/letsencrypt/boulder/test"
4747
)
4848

@@ -135,7 +135,7 @@ type testCtx struct {
135135
caConfig ca_config.CAConfig
136136
pa core.PolicyAuthority
137137
issuers []Issuer
138-
signerConfigs []bsigner.Config
138+
issuerConfigs []issuance.IssuerConfig
139139
keyPolicy goodkey.KeyPolicy
140140
fc clock.FakeClock
141141
stats prometheus.Registerer
@@ -261,12 +261,12 @@ func setup(t *testing.T) *testCtx {
261261

262262
issuers := []Issuer{{caKey, caCert}}
263263

264-
signerConfigs := []bsigner.Config{
264+
issuerConfigs := []issuance.IssuerConfig{
265265
{
266-
Issuer: caCert,
266+
Cert: caCert,
267267
Signer: caKey,
268268
Clk: fc,
269-
Profile: bsigner.ProfileConfig{
269+
Profile: issuance.ProfileConfig{
270270
UseForECDSALeaves: true,
271271
UseForRSALeaves: true,
272272
AllowMustStaple: true,
@@ -276,7 +276,7 @@ func setup(t *testing.T) *testCtx {
276276
IssuerURL: "http://not-example.com/issuer-url",
277277
OCSPURL: "http://not-example.com/ocsp",
278278
CRLURL: "http://not-example.com/crl",
279-
Policies: []bsigner.PolicyInformation{
279+
Policies: []issuance.PolicyInformation{
280280
{OID: "2.23.140.1.2.1"},
281281
},
282282
MaxValidityPeriod: cmd.ConfigDuration{Duration: time.Hour * 8760},
@@ -297,7 +297,7 @@ func setup(t *testing.T) *testCtx {
297297
caConfig,
298298
pa,
299299
issuers,
300-
signerConfigs,
300+
issuerConfigs,
301301
keyPolicy,
302302
fc,
303303
metrics.NoopRegisterer,
@@ -401,13 +401,13 @@ func TestIssuePrecertificate(t *testing.T) {
401401
}
402402
}
403403

404-
func issueCertificateSubTestSetup(t *testing.T, boulderSigner bool) (*CertificateAuthorityImpl, *mockSA) {
404+
func issueCertificateSubTestSetup(t *testing.T, boulderIssuer bool) (*CertificateAuthorityImpl, *mockSA) {
405405
testCtx := setup(t)
406406
sa := &mockSA{}
407407
var issuers []Issuer
408-
var signerConfigs []bsigner.Config
409-
if boulderSigner {
410-
signerConfigs = testCtx.signerConfigs
408+
var issuerConfigs []issuance.IssuerConfig
409+
if boulderIssuer {
410+
issuerConfigs = testCtx.issuerConfigs
411411
_ = features.Set(map[string]bool{"NonCFSSLSigner": true})
412412
} else {
413413
issuers = testCtx.issuers
@@ -419,7 +419,7 @@ func issueCertificateSubTestSetup(t *testing.T, boulderSigner bool) (*Certificat
419419
testCtx.fc,
420420
testCtx.stats,
421421
issuers,
422-
signerConfigs,
422+
issuerConfigs,
423423
testCtx.keyPolicy,
424424
testCtx.logger,
425425
nil)
@@ -847,7 +847,7 @@ func TestIssueCertificateForPrecertificate(t *testing.T) {
847847
testCtx.fc,
848848
testCtx.stats,
849849
testCtx.issuers,
850-
testCtx.signerConfigs,
850+
testCtx.issuerConfigs,
851851
testCtx.keyPolicy,
852852
testCtx.logger,
853853
nil)
@@ -1291,7 +1291,7 @@ func TestGenerateOCSPWithIssuerID(t *testing.T) {
12911291
// GenerateOCSP with feature enabled + req contains good IssuerID
12921292
rsaIssuer := ca.issuers.byAlg[x509.RSA]
12931293
_, err = ca.GenerateOCSP(context.Background(), &capb.GenerateOCSPRequest{
1294-
IssuerID: idForIssuer(rsaIssuer.cert),
1294+
IssuerID: idForCert(rsaIssuer.cert),
12951295
Serial: "DEADDEADDEADDEADDEADDEADDEADDEADDEAD",
12961296
Status: string(core.OCSPStatusGood),
12971297
})

ca/config/config.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"github.com/letsencrypt/pkcs11key/v4"
66

77
"github.com/letsencrypt/boulder/cmd"
8-
"github.com/letsencrypt/boulder/signer"
8+
"github.com/letsencrypt/boulder/issuance"
99
)
1010

1111
// CAConfig structs have configuration information for the certificate
@@ -27,7 +27,7 @@ type CAConfig struct {
2727
Issuers []IssuerConfig
2828
// SignerProfile contains the signer issuance profile, if using the boulder
2929
// signer rather than the CFSSL signer.
30-
SignerProfile signer.ProfileConfig
30+
SignerProfile issuance.ProfileConfig
3131
// LifespanOCSP is how long OCSP responses are valid for; It should be longer
3232
// than the minTimeToExpiry field for the OCSP Updater.
3333
LifespanOCSP cmd.ConfigDuration

cmd/boulder-ca/main.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import (
2222
"github.com/letsencrypt/boulder/features"
2323
"github.com/letsencrypt/boulder/goodkey"
2424
bgrpc "github.com/letsencrypt/boulder/grpc"
25+
"github.com/letsencrypt/boulder/issuance"
2526
"github.com/letsencrypt/boulder/policy"
2627
sapb "github.com/letsencrypt/boulder/sa/proto"
27-
bsigner "github.com/letsencrypt/boulder/signer"
2828
)
2929

3030
type config struct {
@@ -48,15 +48,15 @@ func loadCFSSLIssuers(configs []ca_config.IssuerConfig) ([]ca.Issuer, error) {
4848
return issuers, nil
4949
}
5050

51-
func loadBoulderIssuers(configs []ca_config.IssuerConfig, profile bsigner.ProfileConfig, ignoredLints []string) ([]bsigner.Config, error) {
52-
boulderIssuerConfigs := make([]bsigner.Config, 0, len(configs))
51+
func loadBoulderIssuers(configs []ca_config.IssuerConfig, profile issuance.ProfileConfig, ignoredLints []string) ([]issuance.IssuerConfig, error) {
52+
boulderIssuerConfigs := make([]issuance.IssuerConfig, 0, len(configs))
5353
for _, issuerConfig := range configs {
5454
signer, issuer, err := loadIssuer(issuerConfig)
5555
if err != nil {
5656
return nil, err
5757
}
58-
boulderIssuerConfigs = append(boulderIssuerConfigs, bsigner.Config{
59-
Issuer: issuer,
58+
boulderIssuerConfigs = append(boulderIssuerConfigs, issuance.IssuerConfig{
59+
Cert: issuer,
6060
Signer: signer,
6161
IgnoredLints: ignoredLints,
6262
Clk: cmd.Clock(),
@@ -172,7 +172,7 @@ func main() {
172172
cmd.FailOnError(err, "Couldn't load hostname policy file")
173173

174174
var cfsslIssuers []ca.Issuer
175-
var boulderIssuerConfigs []bsigner.Config
175+
var boulderIssuerConfigs []issuance.IssuerConfig
176176
if features.Enabled(features.NonCFSSLSigner) {
177177
boulderIssuerConfigs, err = loadBoulderIssuers(c.CA.Issuers, c.CA.SignerProfile, c.CA.IgnoredLints)
178178
cmd.FailOnError(err, "Couldn't load issuers")

0 commit comments

Comments
 (0)