Documentation
¶
Overview ¶
Package tlsleaf provides a lazily-generated self-signed CA and per-hostname leaf issuer for the AgentMon DB proxy's TLS termination path. The CA is persisted under a caller-provided StateDir; leaves are issued on demand and cached in-process. Operators copy the CA cert into client trust stores (sslrootcert) so downstream PostgreSQL clients accept proxied connections.
The package is platform-agnostic; tests run on every supported OS.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CA ¶
type CA struct {
// contains filtered or unexported fields
}
CA is the AgentMon-DB self-signed certificate authority. Construct via LoadOrCreate. Methods are safe for concurrent use.
func LoadOrCreate ¶
LoadOrCreate loads the CA from stateDir if both files are present, or generates a fresh CA on first call and persists it (key 0600, cert 0644). stateDir must already exist; the parent of any sub-path is not created.
Manual recovery: if a crash leaves the StateDir with only one of the two files (key without cert, or vice versa), LoadOrCreate refuses to regenerate. Remove the orphaned file by hand and call LoadOrCreate again.
func (*CA) Cert ¶
func (c *CA) Cert() *x509.Certificate
Cert returns the CA certificate. Safe for concurrent use; callers must not mutate the returned value.
func (*CA) IssueLeaf ¶
func (c *CA) IssueLeaf(hostname string) (*tls.Certificate, error)
IssueLeaf returns a tls.Certificate whose leaf is signed by the CA and whose only SAN is hostname. Cached in-process under hostname; cache size is bounded at 256 entries (LRU). Repeated calls for the same hostname return the cached certificate (no re-issuance).