Skip to content

Commit d0d89a7

Browse files
authored
sa: use dummy date instead of zero date (#8481)
Fixes #8466
1 parent 4327f25 commit d0d89a7

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

cmd/bad-key-revoker/main_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,9 @@ func insertCert(t *testing.T, dbMap *db.WrappedMap, fc clock.Clock, keyHash []by
151151
status,
152152
expiredStatus,
153153
fc.Now(),
154-
time.Time{},
154+
time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
155155
0,
156-
time.Time{},
156+
time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC),
157157
)
158158
test.AssertNotError(t, err, "failed to insert test certificateStatus row")
159159

cmd/cert-checker/main_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,8 @@ func TestGetAndProcessCerts(t *testing.T) {
353353
Subject: pkix.Name{
354354
CommonName: "not-blacklisted.com",
355355
},
356+
NotBefore: fc.Now(),
357+
NotAfter: fc.Now().Add(999999 * time.Hour),
356358
BasicConstraintsValid: true,
357359
DNSNames: []string{"not-blacklisted.com"},
358360
ExtKeyUsage: []x509.ExtKeyUsage{x509.ExtKeyUsageServerAuth, x509.ExtKeyUsageClientAuth},

sa/model_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ func insertCertificate(ctx context.Context, dbMap *db.WrappedMap, fc clock.FakeC
329329
}
330330
cert := &core.Certificate{
331331
RegistrationID: regID,
332+
Issued: fc.Now(),
332333
Serial: serialString,
333334
Expires: template.NotAfter,
334335
DER: certDer,

sa/sa.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,14 +245,20 @@ func (ssa *SQLStorageAuthority) AddPrecertificate(ctx context.Context, req *sapb
245245
return nil, err
246246
}
247247

248+
// An arbitrary, but valid date for fields revokedDate and lastExpirationNagSent.
249+
// These fields in the database are NOT NULL so we can't omit them; and we don't
250+
// want to pass `time.Time{}` because that results in inserts of `0000-00-00`, which
251+
// is forbidden in strict mode (when NO_ZERO_DATE is on).
252+
dummyDate := time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
253+
248254
status := core.OCSPStatusGood
249255
cs := &certificateStatusModel{
250256
Serial: serialHex,
251257
Status: status,
252258
OCSPLastUpdated: ssa.clk.Now(),
253-
RevokedDate: time.Time{},
259+
RevokedDate: dummyDate,
254260
RevokedReason: 0,
255-
LastExpirationNagSent: time.Time{},
261+
LastExpirationNagSent: dummyDate,
256262
NotAfter: parsed.NotAfter,
257263
IsExpired: false,
258264
IssuerID: req.IssuerNameID,

0 commit comments

Comments
 (0)