+31
-0
lines changedFilter options
+31
-0
lines changed Original file line number Diff line number Diff line change
@@ -77,6 +77,7 @@ type Accessor interface {
77
77
GetUnexpiredCertificates() ([]CertificateRecord, error)
78
78
GetRevokedAndUnexpiredCertificates() ([]CertificateRecord, error)
79
79
GetRevokedAndUnexpiredCertificatesByLabel(label string) ([]CertificateRecord, error)
80
+
GetRevokedAndUnexpiredCertificatesByLabelSelectColumns(label string) ([]CertificateRecord, error)
80
81
RevokeCertificate(serial, aki string, reasonCode int) error
81
82
InsertOCSP(rr OCSPRecord) error
82
83
GetOCSP(serial, aki string) ([]OCSPRecord, error)
Original file line number Diff line number Diff line change
@@ -36,6 +36,10 @@ SELECT %s FROM certificates
36
36
SELECT %s FROM certificates
37
37
WHERE CURRENT_TIMESTAMP < expiry AND status='revoked' AND ca_label= ?;`
38
38
39
+
selectRevokedAndUnexpiredWithLabelSQL = `
40
+
SELECT serial_number, revoked_at FROM certificates
41
+
WHERE CURRENT_TIMESTAMP < expiry AND status='revoked' AND ca_label= ?;`
42
+
39
43
selectAllRevokedAndUnexpiredSQL = `
40
44
SELECT %s FROM certificates
41
45
WHERE CURRENT_TIMESTAMP < expiry AND status='revoked';`
@@ -202,6 +206,21 @@ func (d *Accessor) GetRevokedAndUnexpiredCertificatesByLabel(label string) (crs
202
206
return crs, nil
203
207
}
204
208
209
+
// GetRevokedAndUnexpiredCertificatesSelectColumnsByLabel gets serial_number and revoed_at from all revoked and unexpired certificate from db (for CRLs) with specified ca_label.
210
+
func (d *Accessor) GetRevokedAndUnexpiredCertificatesByLabelSelectColumns(label string) (crs []certdb.CertificateRecord, err error) {
211
+
err = d.checkDB()
212
+
if err != nil {
213
+
return nil, err
214
+
}
215
+
216
+
err = d.db.Select(&crs, d.db.Rebind(selectRevokedAndUnexpiredWithLabelSQL), label)
217
+
if err != nil {
218
+
return nil, wrapSQLError(err)
219
+
}
220
+
221
+
return crs, nil
222
+
}
223
+
205
224
// RevokeCertificate updates a certificate with a given serial number and marks it revoked.
206
225
func (d *Accessor) RevokeCertificate(serial, aki string, reasonCode int) error {
207
226
err := d.checkDB()
Original file line number Diff line number Diff line change
@@ -280,6 +280,17 @@ func testUpdateCertificateAndGetCertificate(ta TestAccessor, t *testing.T) {
280
280
want.PEM != got.PEM {
281
281
t.Errorf("want Certificate %+v, got %+v", want, got)
282
282
}
283
+
284
+
rets, err = ta.Accessor.GetRevokedAndUnexpiredCertificatesByLabelSelectColumns("")
285
+
if err != nil {
286
+
t.Fatal(err)
287
+
}
288
+
289
+
got = rets[0]
290
+
// reflection comparison with zero time objects are not stable as it seems
291
+
if want.Serial != got.Serial || got.RevokedAt.IsZero() {
292
+
t.Errorf("want Certificate %+v, got %+v", want, got)
293
+
}
283
294
}
284
295
285
296
func testInsertOCSPAndGetOCSP(ta TestAccessor, t *testing.T) {
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4