certstore

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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