Documentation ¶
Overview ¶
Package certdb contains Go definitions for the database representation of certificates, as well as associated code for putting it into the database.
Index ¶
- func Ensure(table Table, tx *sql.Tx) (bool, error)
- func Finalize(err *error, tx *sql.Tx)
- type AIA
- type Certificate
- func (cert *Certificate) Insert(tx *sql.Tx) error
- func (cert *Certificate) Releases(tx *sql.Tx) ([]*Release, error)
- func (cert *Certificate) Revoke(tx *sql.Tx, mechanism, reason string, when int64) error
- func (cert *Certificate) Revoked(tx *sql.Tx, when int64) (bool, error)
- func (cert *Certificate) Select(tx *sql.Tx) error
- func (cert *Certificate) X509() *x509.Certificate
- type CertificateRelease
- type Release
- type Revocation
- type Table
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AIA ¶
AIA models the aia table.
func NewAIA ¶
func NewAIA(cert *Certificate) *AIA
NewAIA populates an AIA structure from a Certificate.
type Certificate ¶
type Certificate struct { SKI string AKI string Serial []byte NotBefore int64 NotAfter int64 Raw []byte // contains filtered or unexported fields } // UNIQUE(ski, serial)
Certificate models the certificate table.
func AllCertificates ¶
func AllCertificates(tx *sql.Tx) ([]*Certificate, error)
AllCertificates loads all the certificates in the database.
func CollectRelease ¶
func CollectRelease(bundle, version string, tx *sql.Tx) ([]*Certificate, error)
CollectRelease grabs all the certificates in a release, ordering them by the oldest.
func FindCertificateBySKI ¶
func FindCertificateBySKI(db *sql.DB, ski string) ([]*Certificate, error)
FindCertificateBySKI returns all the certificates with the given SKI.
func NewCertificate ¶
func NewCertificate(cert *x509.Certificate) *Certificate
NewCertificate creates a Certificate from a crypto/x509 Certificate structure.
func (*Certificate) Insert ¶
func (cert *Certificate) Insert(tx *sql.Tx) error
Insert stores the Certificate in the database.
func (*Certificate) Releases ¶
func (cert *Certificate) Releases(tx *sql.Tx) ([]*Release, error)
Releases looks up all the releases for a certificate.
func (*Certificate) Revoked ¶
Revoked returns true if the certificate was revoked before the timestamp passed in.
func (*Certificate) Select ¶
func (cert *Certificate) Select(tx *sql.Tx) error
Select requires the SKI and Serial fields to be filled in.
func (*Certificate) X509 ¶
func (cert *Certificate) X509() *x509.Certificate
X509 returns the *crypto/x509.Certificate from the certificate.
type CertificateRelease ¶
type CertificateRelease struct { Certificate *Certificate Release *Release }
A CertificateRelease pairs a Certificate and Release to enable adding certificates to the relevant release tables.
func NewCertificateRelease ¶
func NewCertificateRelease(c *Certificate, r *Release) *CertificateRelease
NewCertificateRelease is a convenience function for building a CertificateRelease structure.
func (*CertificateRelease) Insert ¶
func (cr *CertificateRelease) Insert(tx *sql.Tx) error
Insert stores the CertificateRelease in the database. It does no checking to determine if the CertificateRelease is already in the database, and will fail if it's already present in the database (due to UNIQUE constraints).
type Release ¶
type Release struct { Bundle string // Is this a CA or intermediate release? Version string ReleasedAt int64 }
Release models the root_releases and intermediate_releases tables.
func AllReleases ¶
AllReleases returns the list of all releases, sorted in reverse chronological order.
func FetchRelease ¶
FetchRelease looks for the specified release. It does its own transaction to match the style of the other release fetching functions.
func LatestRelease ¶
LatestRelease returns the latest release.
func NewRelease ¶
NewRelease verifies the bundle is valid, and creates a new Release with the current time stamp.
func (*Release) Count ¶
Count requires the Release to be Selectable, and will return the number of certificates in the release.
type Revocation ¶
Revocation models the revocations table.
type Table ¶
type Table interface { // Insert stores a value in the database; it doesn't check // whether the value exists in the database already and isn't // idempotent --- calling it twice on the same value will // likely violate UNIQUE constraints. Insert(tx *sql.Tx) error // Select fills in the value given certain primary fields // being filled in. The function comment for each struct's // implementation should note which fields should be filled in // prior to calling this. It should also return sql.ErrNoRows // if the item doesn't exist in the database. Select(tx *sql.Tx) error }
Table provides an interface for mapping a struct to a table in the database.