certstore

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Overview

Package certstore keeps the edge's certificates, ACME account, and challenge data where several edges can share them: a Vault KV v2 path, with the edge's own disk as the copy it serves from when Vault cannot be reached (Shared).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Remote

type Remote interface {
	certmagic.Storage
}

Remote is the shared store: Vault.

type Shared

type Shared struct {
	Local  certmagic.Storage
	Remote Remote
	// contains filtered or unexported fields
}

Shared is certmagic.Storage on the edge's disk and a store the edges share. The shared store is the truth: every read asks it first, so a certificate another edge obtained or renewed is used, and keeps a copy on disk; every write goes to disk, then to the shared store. A key the shared store does not have is not there, unless this edge wrote it while the store was down and has not got it there yet (pending).

When the shared store cannot be reached, the disk serves alone: the edge keeps its certificates, renews them by itself (the shared lock falls back to the disk's), and writes what the store missed once it is back. An unreachable store is not asked again for downFor, so boot does not wait on it call after call. Run first writes what the disk has and the store does not: an edge that kept its certificates on disk before shares them, rather than order them again.

func NewShared

func NewShared(local certmagic.Storage, remote Remote) *Shared

func (*Shared) Delete

func (s *Shared) Delete(ctx context.Context, key string) error

func (*Shared) Exists

func (s *Shared) Exists(ctx context.Context, key string) bool

func (*Shared) List

func (s *Shared) List(ctx context.Context, prefix string, recursive bool) ([]string, error)

List is what the shared store has under prefix, and the pending keys there; the disk's, when the store is down.

func (*Shared) Load

func (s *Shared) Load(ctx context.Context, key string) ([]byte, error)

func (*Shared) Lock

func (s *Shared) Lock(ctx context.Context, name string) error

Lock takes the shared lock, so two edges do not order the same certificate at once; with the store down, the disk's.

func (*Shared) Run

func (s *Shared) Run(ctx context.Context)

Run writes the keys the shared store missed until ctx ends.

func (*Shared) Seed

func (s *Shared) Seed(ctx context.Context)

Seed marks the keys on disk that the shared store lacks as pending, once, when the store answers.

func (*Shared) Stat

func (s *Shared) Stat(ctx context.Context, key string) (certmagic.KeyInfo, error)

func (*Shared) Status

func (s *Shared) Status() map[string]any

Status is the shared store's health, for the status's cert_store.

func (*Shared) Store

func (s *Shared) Store(ctx context.Context, key string, value []byte) error

func (*Shared) Unlock

func (s *Shared) Unlock(ctx context.Context, name string) error

func (*Shared) WriteMetrics

func (s *Shared) WriteMetrics(w *metrics.Writer)

type Vault

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

Vault is certmagic.Storage on a KV v2 path. Each key is a secret at <path>/<key> holding the value; a lock is a secret at <path>/_locks/<name>, created only where none is (check-and-set 0), so two edges cannot both take it.

func NewVault

func NewVault(cfg VaultConfig) (*Vault, error)

func (*Vault) Delete

func (v *Vault) Delete(ctx context.Context, key string) error

func (*Vault) Exists

func (v *Vault) Exists(ctx context.Context, key string) bool

func (*Vault) List

func (v *Vault) List(ctx context.Context, prefix string, recursive bool) ([]string, error)

List lists keys under prefix, as FileStorage does: with recursive, "directories" and everything under them.

func (*Vault) Load

func (v *Vault) Load(ctx context.Context, key string) ([]byte, error)

func (*Vault) Lock

func (v *Vault) Lock(ctx context.Context, name string) error

Lock takes the lock name, waiting while another edge holds it and has refreshed it within lockTTL.

func (*Vault) Stat

func (v *Vault) Stat(ctx context.Context, key string) (certmagic.KeyInfo, error)

func (*Vault) Store

func (v *Vault) Store(ctx context.Context, key string, value []byte) error

func (*Vault) Unlock

func (v *Vault) Unlock(ctx context.Context, name string) error

Unlock releases a lock this edge holds: it deletes the lock, unless another edge took it over meanwhile.

type VaultConfig

type VaultConfig struct {
	URL      string // https://vault.example.com:8200
	CA       []byte // PEM: the only roots the connection trusts; empty is the system's
	Mount    string // the KV v2 mount, such as edge-certs
	Path     string // the edges' path in it, such as test/private
	RoleID   string // AppRole
	SecretID string
}

VaultConfig is how the edge reaches its Vault path.

Directories

Path Synopsis
Package vaulttest is a Vault server for tests: AppRole login and token renewal, and one KV v2 mount with check-and-set, metadata, and lists, answering as Vault does, behind TLS.
Package vaulttest is a Vault server for tests: AppRole login and token renewal, and one KV v2 mount with check-and-set, metadata, and lists, answering as Vault does, behind TLS.

Jump to

Keyboard shortcuts

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