certpg

package
v0.11.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 16 Imported by: 0

README

PostgreSQL schema

Documentation

Index

Constants

View Source
const SelectDnsnameLike = `SELECT * FROM CERTDB_dnsnames WHERE dnsname LIKE $1;`
View Source
const SelectEstimate = `SELECT reltuples AS estimate FROM pg_class WHERE relname = $1;`
View Source
const SelectMaxIndex = `SELECT MAX(logindex) AS logindex FROM CERTDB_entry WHERE stream = $1;`
View Source
const SelectMinIndex = `SELECT MIN(logindex) AS logindex FROM CERTDB_entry WHERE stream = $1;`

Variables

View Source
var BulkRange = int64(4096)
View Source
var FunctionName string
View Source
var FunctionOperatorID string
View Source
var FunctionStreamID string
View Source
var ProcedureCreateSchema string
View Source
var ProcedureNewEntry string
View Source
var SelectGaps string

Functions

func ScanCertificate added in v0.11.0

func ScanCertificate(row Scanner, cert *Certificate) (err error)

func ScanDnsname added in v0.11.0

func ScanDnsname(row Scanner, p *Dnsname) error

func ScanDnsnamesView added in v0.11.0

func ScanDnsnamesView(row Scanner, dnsname *DnsnamesView) (err error)

func ScanIdent added in v0.11.0

func ScanIdent(row Scanner, ident *Ident) error

func ScanLogEntry added in v0.11.0

func ScanLogEntry(row Scanner, entry *LogEntry) (err error)

Types

type CertPG

type CertPG struct {
	*sql.DB
	certstream.Logger
	Backfill              bool                // if true, fill in missing entries in database
	bwlimit.ContextDialer                     // if not nil, ContextDialer used for backfilling
	Pfx                   func(string) string // prefix replacer
	// contains filtered or unexported fields
}

CertPG integrates with sql.DB to manage certificate stream data for a PostgreSQL database

func New

func New(ctx context.Context, cd bwlimit.ContextDialer, db *sql.DB, prefix string) (cdb *CertPG, err error)

New creates a CertPG and creates the needed tables and indices if they don't exist.

func (*CertPG) BackfillStream added in v0.3.0

func (cdb *CertPG) BackfillStream(ctx context.Context, ls *certstream.LogStream)

func (*CertPG) Close

func (cdb *CertPG) Close() error

Close frees resources used.

func (*CertPG) Entry

func (cdb *CertPG) Entry(ctx context.Context, le *certstream.LogEntry) (err error)

func (*CertPG) Estimate added in v0.8.0

func (cdb *CertPG) Estimate(table string) (estimate float64, err error)

func (*CertPG) GetCertificateByHash added in v0.11.0

func (cdb *CertPG) GetCertificateByHash(ctx context.Context, hash []byte) (cert *certjson.Certificate, err error)

func (*CertPG) GetCertificateByID added in v0.11.0

func (cdb *CertPG) GetCertificateByID(ctx context.Context, id int64) (cert *certjson.Certificate, err error)

func (*CertPG) GetCertificateByLogEntry added in v0.11.0

func (cdb *CertPG) GetCertificateByLogEntry(ctx context.Context, entry *LogEntry) (cert *certjson.Certificate, err error)

func (*CertPG) LogError

func (cdb *CertPG) LogError(err error, msg string, args ...any) error

func (*CertPG) Operator

func (cdb *CertPG) Operator(ctx context.Context, lo *certstream.LogOperator) (err error)

func (*CertPG) Stream

func (cdb *CertPG) Stream(ctx context.Context, ls *certstream.LogStream) (err error)

type Certificate added in v0.11.0

type Certificate struct {
	Id         int64
	NotBefore  time.Time
	NotAfter   time.Time
	CommonName string
	SubjectID  int
	IssuerID   int
	Sha256     []byte
	PreCert    bool
}

type Dnsname added in v0.7.0

type Dnsname struct {
	Dnsname string
	CertID  int64
}

type DnsnamesView added in v0.11.0

type DnsnamesView struct {
	CertID    int64
	DNSName   string
	NotBefore time.Time
	Idna      bool
	Valid     bool
	PreCert   bool
	Issuer    string
	Subject   string
	Crtsh     string
}

type Ident added in v0.11.0

type Ident struct {
	Id           int
	Organization string
	Province     string
	Country      string
}

type LogEntry added in v0.11.0

type LogEntry struct {
	Seen     time.Time // CT log entry timestamp
	LogIndex int64     // CT log index for the stream
	CertID   int64     // database ID of cert
	StreamID int       // database ID of stream
}

type Scanner added in v0.11.0

type Scanner interface {
	Scan(dest ...any) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL