certstore

package
v0.2.0-rc.5 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodePEM

func DecodePEM(data []byte) ([]*pem.Block, error)

DecodePEM is a helper to decode PEM blocks from raw bytes.

Types

type CertMeta

type CertMeta struct {
	Domain    string   `json:"domain"`
	SANs      []string `json:"sans,omitempty"`
	Issuer    string   `json:"issuer,omitempty"`
	NotBefore string   `json:"not_before,omitempty"`
	NotAfter  string   `json:"not_after,omitempty"`
	Source    Source   `json:"source"`
	KeyType   string   `json:"key_type,omitempty"`
	AutoRenew bool     `json:"auto_reew"`
}

CertMeta is metadata for a stored certificate.

type Source

type Source string

Source identifies how a certificate was obtained.

const (
	SourceACME   Source = "acme"
	SourceManual Source = "manual"
)

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store implements engine.CertProvider and provides certificate management capabilities including manual PEM import and metadata tracking.

func New

func New(acmeMgr *acme.Manager, cacheDir string) *Store

New creates a certificate store. acmeMgr may be nil (manual-only mode). cacheDir is used for persistence; empty means no persistence.

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, domain string) error

Delete removes a certificate. For ACME certs, removes metadata only. For manual certs, also removes PEM files from disk.

func (*Store) Get

func (s *Store) Get(domain string) (CertMeta, bool)

Get returns metadata for a single domain.

func (*Store) GetCertificate

func (s *Store) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate returns a TLS certificate for the given SNI name. Implements engine.CertProvider. Checks manual certs first, then ACME.

func (*Store) Import

func (s *Store) Import(ctx context.Context, domain string, certPEM, keyPEM []byte) (*CertMeta, error)

Import stores a manually provided PEM certificate+key pair.

func (*Store) List

func (s *Store) List() []CertMeta

List returns metadata for all stored certificates.

func (*Store) Load

func (s *Store) Load(ctx context.Context) error

Load reads persisted metadata and manual certificates from disk. Call this once after New, before first use.

func (*Store) Obtain

func (s *Store) Obtain(ctx context.Context, domains []string) error

Obtain requests a certificate via ACME for the given domains. Implements engine.CertProvider.

func (*Store) RefreshACME

func (s *Store) RefreshACME(domains []string)

RefreshACME updates metadata for ACME-obtained certs after renewal. Called by the acme.Manager onObtain callback.

Jump to

Keyboard shortcuts

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