{"modulePath":"github.com/REDNIXON/CFSSL","version":"v0.0.0-20191102213046-bef4a90089c3","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package sql\n\n## Types\n\n```go\ntype Accessor struct {\n\t// contains filtered or unexported fields\n}\n```\nAccessor implements certdb.Accessor interface.\n\n```go\nfunc NewAccessor(db *sqlx.DB) *Accessor\n```\nNewAccessor returns a new Accessor.\n\n```go\nfunc (d *Accessor) GetCertificate(serial, aki string) (crs []certdb.CertificateRecord, err error)\n```\nGetCertificate gets a certdb.CertificateRecord indexed by serial.\n\n```go\nfunc (d *Accessor) GetOCSP(serial, aki string) (ors []certdb.OCSPRecord, err error)\n```\nGetOCSP retrieves a certdb.OCSPRecord from db by serial.\n\n```go\nfunc (d *Accessor) GetRevokedAndUnexpiredCertificates() (crs []certdb.CertificateRecord, err error)\n```\nGetRevokedAndUnexpiredCertificates gets all revoked and unexpired certificate from db (for CRLs).\n\n```go\nfunc (d *Accessor) GetRevokedAndUnexpiredCertificatesByLabel(label string) (crs []certdb.CertificateRecord, err error)\n```\nGetRevokedAndUnexpiredCertificatesByLabel gets all revoked and unexpired certificate from db (for CRLs) with specified ca\\_label.\n\n```go\nfunc (d *Accessor) GetUnexpiredCertificates() (crs []certdb.CertificateRecord, err error)\n```\nGetUnexpiredCertificates gets all unexpired certificate from db.\n\n```go\nfunc (d *Accessor) GetUnexpiredCertificatesByAKI(aki string) (crs []certdb.CertificateRecord, err error)\n```\nGetUnexpiredCertificatesByAKI gets all unexpired certificate from db, filtered by AKI\n\n```go\nfunc (d *Accessor) GetUnexpiredOCSPs() (ors []certdb.OCSPRecord, err error)\n```\nGetUnexpiredOCSPs retrieves all unexpired certdb.OCSPRecord from db.\n\n```go\nfunc (d *Accessor) InsertCertificate(cr certdb.CertificateRecord) error\n```\nInsertCertificate puts a certdb.CertificateRecord into db.\n\n```go\nfunc (d *Accessor) InsertOCSP(rr certdb.OCSPRecord) error\n```\nInsertOCSP puts a new certdb.OCSPRecord into the db.\n\n```go\nfunc (d *Accessor) RevokeCertificate(serial, aki string, reasonCode int) error\n```\nRevokeCertificate updates a certificate with a given serial number and marks it revoked.\n\n```go\nfunc (d *Accessor) SetDB(db *sqlx.DB)\n```\nSetDB changes the underlying sql.DB object Accessor is manipulating.\n\n```go\nfunc (d *Accessor) UpdateOCSP(serial, aki, body string, expiry time.Time) error\n```\nUpdateOCSP updates a ocsp response record with a given serial number.\n\n```go\nfunc (d *Accessor) UpsertOCSP(serial, aki, body string, expiry time.Time) error\n```\nUpsertOCSP update a ocsp response record with a given serial number, or insert the record if it doesn't yet exist in the db Implementation note: We didn't implement 'upsert' with SQL statement and we lost race condition prevention provided by underlying DBMS. Reasoning: 1. it's diffcult to support multiple DBMS backends in the same time, the SQL syntax differs from one to another. 2. we don't need a strict simultaneous consistency between OCSP and certificate status. It's OK that a OCSP response still shows 'good' while the corresponding certificate is being revoked seconds ago, as long as the OCSP response catches up to be eventually consistent (within hours to days). Write race condition between OCSP writers on OCSP table is not a problem, since we don't have write race condition on Certificate table and OCSP writers should periodically use Certificate table to update OCSP table to catch up.\n\n","path":"github.com/REDNIXON/CFSSL/certdb/sql","name":"sql","synopsis":"","isRedistributable":true}
