certissuer

package
v0.14.2 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2026 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConfig      = errors.New("cert issuer: invalid config")
	ErrInvalidArgs = errors.New("cert issuer: invalid args")
)
View Source
var (
	ErrExternalAccountBindingRequired = errors.New("server requires External Account Binding")
	ErrUnsupportedDNSProvider         = errors.New("unsupported DNS provider")
)
View Source
var (
	ErrStorageUnknownPrivateKeyType = errors.New("cert storage: invalid private key type")
	ErrStorageParse                 = errors.New("cert storage: parse")
	ErrStorageParsePrivateKey       = errors.New("cert storage: unable to parse private key")
	ErrStorageParseCertificate      = errors.New("cert storage: unable to parse certificate")
	ErrStorageUnsupportedKeyType    = errors.New("cert storage: unsupported private key type")
	ErrStorageMissingPrivateKey     = errors.New("cert storage: missing private key")
	ErrStorageInvalidPFXFormat      = errors.New("cert storage: invalid PFX format")
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Email        string                 `json:"email"`
	Registration *registration.Resource `json:"registration"`
	// contains filtered or unexported fields
}

The Account represents a users' local saved credential.

func (*Account) GetEmail

func (a *Account) GetEmail() string

GetEmail returns the email address for the account.

func (*Account) GetPrivateKey

func (a *Account) GetPrivateKey() crypto.PrivateKey

GetPrivateKey returns the private RSA account key.

func (*Account) GetRegistration

func (a *Account) GetRegistration() *registration.Resource

GetRegistration returns the server registration.

type CertIssuer

type CertIssuer interface {
	Close() error
}

func NewLego

func NewLego(ctx context.Context, log log.Logger, cfg Config) (CertIssuer, error)

NewLego initializes and returns a certificate issuer based on the ACME protocol using the Lego library. It manages certificate operations through DNS validation challenges.

Parameters:

  • ctx: Parent context for lifecycle management
  • log: Logger for operation and error reporting
  • cfg: Configuration containing ACME server, account details, and DNS providers

The function performs several key operations:

  • Sets up local storage for account persistence
  • Configures and creates a Lego client with retry capability
  • Handles ACME account registration (with External Account Binding if required)
  • Initializes configured DNS providers (supports gcloud and Cloudflare)
  • Starts a background process for certificate management

Returns a CertIssuer interface and any error encountered during setup.

type Config

type Config struct {
	Bus                      tpubsub.Publisher
	Email                    string
	Owner                    sdk.Address
	KID                      string
	HMAC                     string
	StorageDir               string
	CADirURL                 string
	Domains                  []string
	HTTPChallengePort        int
	TLSChallengePort         int
	DNSProviders             []string
	DNSResolvers             []string
	DNSTimeout               time.Duration
	DNSPropagationWait       time.Duration
	DNSPropagationRNS        bool
	DNSDisableCP             bool
	DNSPropagationDisableANS bool
}

func (Config) Validate

func (c Config) Validate() error

type Reader

type Reader interface {
	ReadResource(domain string) (*certificate.Resource, ResourcesInfo, error)
}

type ResourcesInfo

type ResourcesInfo struct {
	Domain         string `json:"domain"`
	CertFile       string `json:",omitempty"`
	CertIssuerFile string `json:",omitempty"`
	KeyFile        string `json:",omitempty"`
	PemFile        string `json:",omitempty"`
	PfxFile        string `json:",omitempty"`
}

type Storage

type Storage interface {
	AccountSetup() (*Account, certcrypto.KeyType, error)
	AccountSave(*Account) error
	AccountLoad(crypto.PrivateKey) (*Account, error)
	GetPrivateKey(certcrypto.KeyType) (crypto.PrivateKey, error)
	ArchiveDomain(string) error
	SaveResource(resource *certificate.Resource) (ResourcesInfo, error)
	Reader
}

func NewStorage

func NewStorage(log log.Logger, cfg StorageConfig) (Storage, error)

NewStorage Creates a new AccountsStorage.

type StorageConfig

type StorageConfig struct {
	CADirURL    string
	UserID      string
	RootPath    string
	PEM         bool
	PFX         bool
	PFXPassword string
	PFXFormat   string
	// Deprecated
	Filename string
}

type WriteOption

type WriteOption func(*writeOptions) error

Jump to

Keyboard shortcuts

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