github.com/hellobchain/third_party@v0.0.0-20230331131523-deb0478a2e52/cloudflare/cfssl/certdb/certdb.go (about)

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