certdb.go 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package certdb
  2. import (
  3. "time"
  4. )
  5. // CertificateRecord encodes a certificate and its metadata
  6. // that will be recorded in a database.
  7. type CertificateRecord struct {
  8. Serial string `db:"serial_number"`
  9. AKI string `db:"authority_key_identifier"`
  10. CALabel string `db:"ca_label"`
  11. Status string `db:"status"`
  12. Reason int `db:"reason"`
  13. Expiry time.Time `db:"expiry"`
  14. RevokedAt time.Time `db:"revoked_at"`
  15. PEM string `db:"pem"`
  16. }
  17. // OCSPRecord encodes a OCSP response body and its metadata
  18. // that will be recorded in a database.
  19. type OCSPRecord struct {
  20. Serial string `db:"serial_number"`
  21. AKI string `db:"authority_key_identifier"`
  22. Body string `db:"body"`
  23. Expiry time.Time `db:"expiry"`
  24. }
  25. // Accessor abstracts the CRUD of certdb objects from a DB.
  26. type Accessor interface {
  27. InsertCertificate(cr CertificateRecord) error
  28. GetCertificate(serial, aki string) ([]CertificateRecord, error)
  29. GetUnexpiredCertificates() ([]CertificateRecord, error)
  30. GetRevokedAndUnexpiredCertificates() ([]CertificateRecord, error)
  31. GetRevokedAndUnexpiredCertificatesByLabel(label string) ([]CertificateRecord, error)
  32. RevokeCertificate(serial, aki string, reasonCode int) error
  33. InsertOCSP(rr OCSPRecord) error
  34. GetOCSP(serial, aki string) ([]OCSPRecord, error)
  35. GetUnexpiredOCSPs() ([]OCSPRecord, error)
  36. UpdateOCSP(serial, aki, body string, expiry time.Time) error
  37. UpsertOCSP(serial, aki, body string, expiry time.Time) error
  38. }