Skip to content

Commit cd24b9d

Browse files
authored
ca: deprecate StoreLintingCertificateInsteadOfPrecertificate (#6970)
And turn off the orphan queue in config-next.
1 parent 0337fb8 commit cd24b9d

File tree

6 files changed

+31
-143
lines changed

6 files changed

+31
-143
lines changed

ca/ca.go

Lines changed: 14 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -220,43 +220,14 @@ func (ca *certificateAuthorityImpl) IssuePrecertificate(ctx context.Context, iss
220220
return nil, err
221221
}
222222

223-
precertDER, issuer, err := ca.issuePrecertificateInner(ctx, issueReq, serialBigInt, validity)
223+
precertDER, _, err := ca.issuePrecertificateInner(ctx, issueReq, serialBigInt, validity)
224224
if err != nil {
225225
return nil, err
226226
}
227-
issuerNameID := issuer.Cert.NameID()
228227

229-
req := &sapb.AddCertificateRequest{
230-
Der: precertDER,
231-
RegID: regID,
232-
Issued: nowNanos,
233-
IssuerNameID: int64(issuerNameID),
234-
}
235-
236-
if features.Enabled(features.StoreLintingCertificateInsteadOfPrecertificate) {
237-
_, err = ca.sa.SetCertificateStatusReady(ctx, &sapb.Serial{Serial: serialHex})
238-
if err != nil {
239-
return nil, err
240-
}
241-
} else {
242-
_, err = ca.sa.AddPrecertificate(ctx, req)
243-
if err != nil {
244-
ca.orphanCount.With(prometheus.Labels{"type": "precert"}).Inc()
245-
err = berrors.InternalServerError(err.Error())
246-
// Note: This log line is parsed by cmd/orphan-finder. If you make any
247-
// changes here, you should make sure they are reflected in orphan-finder.
248-
ca.log.AuditErrf("Failed RPC to store at SA, orphaning precertificate: serial=[%s], cert=[%s], issuerID=[%d], regID=[%d], orderID=[%d], err=[%v]",
249-
serialHex, hex.EncodeToString(precertDER), issuerNameID, issueReq.RegistrationID, issueReq.OrderID, err)
250-
if ca.orphanQueue != nil {
251-
ca.queueOrphan(&orphanedCert{
252-
DER: precertDER,
253-
RegID: regID,
254-
Precert: true,
255-
IssuerID: int64(issuerNameID),
256-
})
257-
}
258-
return nil, err
259-
}
228+
_, err = ca.sa.SetCertificateStatusReady(ctx, &sapb.Serial{Serial: serialHex})
229+
if err != nil {
230+
return nil, err
260231
}
261232

262233
return &capb.IssuePrecertificateResponse{
@@ -460,18 +431,16 @@ func (ca *certificateAuthorityImpl) issuePrecertificateInner(ctx context.Context
460431
return nil, nil, berrors.InternalServerError("failed to prepare precertificate signing: %s", err)
461432
}
462433

463-
if features.Enabled(features.StoreLintingCertificateInsteadOfPrecertificate) {
464-
nowNanos := ca.clk.Now().UnixNano()
465-
_, err = ca.sa.AddPrecertificate(context.Background(), &sapb.AddCertificateRequest{
466-
Der: lintCertBytes,
467-
RegID: issueReq.RegistrationID,
468-
Issued: nowNanos,
469-
IssuerNameID: int64(issuer.Cert.NameID()),
470-
OcspNotReady: true,
471-
})
472-
if err != nil {
473-
return nil, nil, err
474-
}
434+
nowNanos := ca.clk.Now().UnixNano()
435+
_, err = ca.sa.AddPrecertificate(context.Background(), &sapb.AddCertificateRequest{
436+
Der: lintCertBytes,
437+
RegID: issueReq.RegistrationID,
438+
Issued: nowNanos,
439+
IssuerNameID: int64(issuer.Cert.NameID()),
440+
OcspNotReady: true,
441+
})
442+
if err != nil {
443+
return nil, nil, err
475444
}
476445

477446
certDER, err := issuer.Issue(issuanceToken)

ca/ca_test.go

Lines changed: 1 addition & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import (
2424
"github.com/jmhodges/clock"
2525
"github.com/prometheus/client_golang/prometheus"
2626
"google.golang.org/grpc"
27-
"google.golang.org/grpc/codes"
28-
"google.golang.org/grpc/status"
2927
"google.golang.org/protobuf/types/known/emptypb"
3028

3129
capb "github.com/letsencrypt/boulder/ca/proto"
@@ -150,7 +148,7 @@ func (m *mockSA) GetCertificate(ctx context.Context, req *sapb.Serial, _ ...grpc
150148
}
151149

152150
func (m *mockSA) SetCertificateStatusReady(ctx context.Context, req *sapb.Serial, _ ...grpc.CallOption) (*emptypb.Empty, error) {
153-
return nil, status.Error(codes.Unimplemented, "unimplemented mock")
151+
return &emptypb.Empty{}, nil
154152
}
155153

156154
var caKey crypto.Signer
@@ -946,74 +944,6 @@ func (qsa *queueSA) AddPrecertificate(ctx context.Context, req *sapb.AddCertific
946944
return nil, nil
947945
}
948946

949-
// TestPrecertOrphanQueue tests that IssuePrecertificate writes precertificates
950-
// to the orphan queue if storage fails, and that `integrateOrphan` later
951-
// successfully writes those precertificates to the database. To do this, it
952-
// uses the `queueSA` mock, which allows us to flip on and off a "fail" bit that
953-
// decides whether it errors in response to storage requests.
954-
func TestPrecertOrphanQueue(t *testing.T) {
955-
tmpDir := t.TempDir()
956-
orphanQueue, err := goque.OpenQueue(tmpDir)
957-
test.AssertNotError(t, err, "Failed to open orphaned certificate queue")
958-
959-
qsa := &queueSA{fail: true}
960-
testCtx := setup(t)
961-
fakeNow := time.Date(2019, 9, 20, 0, 0, 0, 0, time.UTC)
962-
testCtx.fc.Set(fakeNow)
963-
ca, err := NewCertificateAuthorityImpl(
964-
qsa,
965-
testCtx.pa,
966-
testCtx.boulderIssuers,
967-
nil,
968-
testCtx.certExpiry,
969-
testCtx.certBackdate,
970-
testCtx.serialPrefix,
971-
testCtx.maxNames,
972-
testCtx.keyPolicy,
973-
orphanQueue,
974-
testCtx.logger,
975-
testCtx.stats,
976-
testCtx.signatureCount,
977-
testCtx.signErrorCount,
978-
testCtx.fc)
979-
test.AssertNotError(t, err, "Failed to create CA")
980-
981-
err = ca.integrateOrphan()
982-
if err != goque.ErrEmpty {
983-
t.Fatalf("Unexpected error, wanted %q, got %q", goque.ErrEmpty, err)
984-
}
985-
986-
_, err = ca.IssuePrecertificate(context.Background(), &capb.IssueCertificateRequest{
987-
RegistrationID: 1,
988-
OrderID: 1,
989-
Csr: CNandSANCSR,
990-
})
991-
test.AssertError(t, err, "Expected IssuePrecertificate to fail with `qsa.fail = true`")
992-
993-
matches := testCtx.logger.GetAllMatching(`orphaning precertificate.* regID=\[1\], orderID=\[1\]`)
994-
if len(matches) != 1 {
995-
t.Errorf("no log line, or incorrect log line for orphaned precertificate:\n%s",
996-
strings.Join(testCtx.logger.GetAllMatching(".*"), "\n"))
997-
}
998-
999-
test.AssertMetricWithLabelsEquals(
1000-
t, ca.orphanCount, prometheus.Labels{"type": "precert"}, 1)
1001-
1002-
qsa.fail = false
1003-
err = ca.integrateOrphan()
1004-
test.AssertNotError(t, err, "integrateOrphan failed")
1005-
if !qsa.issuedPrecert.Equal(fakeNow) {
1006-
t.Errorf("expected issued time to be %s, got %s", fakeNow, qsa.issuedPrecert)
1007-
}
1008-
err = ca.integrateOrphan()
1009-
if err != goque.ErrEmpty {
1010-
t.Fatalf("Unexpected error, wanted %q, got %q", goque.ErrEmpty, err)
1011-
}
1012-
1013-
test.AssertMetricWithLabelsEquals(
1014-
t, ca.adoptedOrphanCount, prometheus.Labels{"type": "precert"}, 1)
1015-
}
1016-
1017947
func TestOrphanQueue(t *testing.T) {
1018948
tmpDir := t.TempDir()
1019949
orphanQueue, err := goque.OpenQueue(tmpDir)

features/featureflag_string.go

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

features/features.go

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ const (
1616
StoreRevokerInfo
1717
ROCSPStage6
1818
ROCSPStage7
19+
StoreLintingCertificateInsteadOfPrecertificate
1920

2021
// Currently in-use features
2122
// Check CAA and respect validationmethods parameter.
@@ -67,14 +68,6 @@ const (
6768
// According to the BRs Section 7.1.4.2.2(a), the commonName field is
6869
// Deprecated, and its inclusion is discouraged but not (yet) prohibited.
6970
RequireCommonName
70-
71-
// StoreLintingCertificateInsteadOfPrecertificate stores a copy of the fake
72-
// certificate we use for linting in the `precertificates` table. This
73-
// allows us to write something useful to the database before signing
74-
// anything with a real issuer certificate, so we can treat it as if it
75-
// was issued even if there is a power outage or other error between
76-
// signing the precertificate and writing it to the database.
77-
StoreLintingCertificateInsteadOfPrecertificate
7871
)
7972

8073
// List of features and their default value, protected by fMu

test/config-next/ca-a.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,11 @@
111111
"blockedKeyFile": "test/example-blocked-keys.yaml",
112112
"fermatRounds": 100
113113
},
114-
"orphanQueueDir": "/tmp/orphaned-certificates-a",
115114
"ocspLogMaxLength": 4000,
116115
"ocspLogPeriod": "500ms",
117116
"ecdsaAllowListFilename": "test/config-next/ecdsaAllowList.yml",
118117
"ctLogListFile": "test/ct-test-srv/log_list.json",
119118
"features": {
120-
"StoreLintingCertificateInsteadOfPrecertificate": true,
121119
"RequireCommonName": false
122120
}
123121
},

test/config-next/ca-b.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,11 @@
111111
"blockedKeyFile": "test/example-blocked-keys.yaml",
112112
"fermatRounds": 100
113113
},
114-
"orphanQueueDir": "/tmp/orphaned-certificates-b",
115114
"ocspLogMaxLength": 4000,
116115
"ocspLogPeriod": "500ms",
117116
"ecdsaAllowListFilename": "test/config-next/ecdsaAllowList.yml",
118117
"ctLogListFile": "test/ct-test-srv/log_list.json",
119118
"features": {
120-
"StoreLintingCertificateInsteadOfPrecertificate": true,
121119
"RequireCommonName": false
122120
}
123121
},

0 commit comments

Comments
 (0)