pebble

package
v0.0.0-...-022cf4b Latest Latest
Warning

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

Go to latest
Published: Aug 24, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

README

Package cloudeng.io/webapp/webauth/acme/pebble

import cloudeng.io/webapp/webauth/acme/pebble

Types

Type Config
type Config struct {
	Address           string
	ManagementAddress string
	HTTPPort          int
	TLSPort           int
	Certificate       []byte
	CertificateFile   string
	CAFile            string
	TestCertBase      string
	RootCertURL       string
	// contains filtered or unexported fields
}

Config represents the configuration for a pebble instance that's relevant to using it for testing clients.

Functions
func NewConfig(opt ...ConfigOption) Config

NewConfig creates a new Config instance with default values.

Methods
func (pc Config) CA() *x509.CertPool

CA returns a CertPool containing the root pebble CA certificate. Use it when configuring clients to connect to the pebble instance.

func (pc Config) CARootsURL(id int) string

CARootsURL returns the URL from which the pebble root CA certificate can be retrieved, use 0 as the id.

func (pc *Config) CreateCertsAndUpdateConfig(ctx context.Context, outputDir string) (string, error)

CreateCertsAndUpdateConfig uses minica to create a self-signed certificate for use with the pebble instance and applies any other config customizations requested by any ConfigOptions. The generated certificate and key are placed in outputDir. It returns the path to the possibly updated configuration file to be used when starting pebble. Use minica to create a self-signed certificate for the domain as per:

	  minica -ca-cert pebble.minica.pem \
          -ca-key pebble.minica.key.pem \
          -domains localhost,pebble \
          -ip-addresses 127.0.0.1
func (pc Config) DirectoryURL() string

DirectoryURL returns the ACME service 'directory' URL.

func (pc Config) GetIssuingCA(ctx context.Context, id int) (*x509.CertPool, error)

IssuingCA returns a CertPool containing the issuing CA certificate used by pebble to sign issued certificates.

func (pc Config) GetIssuingCert(ctx context.Context, id int) ([]byte, error)

GetIssuingCert retrieves the pebble certificate, including intermediates, used to sign issued certificates.

func (pc Config) PossibleValidityPeriods() []time.Duration

PossibleValidityPeriods returns the validity periods specified across all defined profiles in the pebble config.

func (pc Config) ValidateCertificate(ctx context.Context, cert *x509.Certificate, intermediates *x509.CertPool) error
Type ConfigOption
type ConfigOption func(*configOption)

ConfigOption represents an option for configuring a new Config instance.

Functions
func WithAlternatePorts(managementPort, serverPort int) ConfigOption

WithAlternatePorts returns a ConfigOption that sets alternate ports for the pebble management and server ports.

func WithValidityPeriod(secs int) ConfigOption

WithValidityPeriod returns a ConfigOption that sets the validity period for all issued certificates by modifying the value in all pebble profiles.

Type ServerOption
type ServerOption func(*serverOptions)

ServerOption represents a option for configuring a new Pebble instance.

Functions
func WithNoSleep() ServerOption

WithNoSleep returns a ServerOption that disables sleeps in pebble to speed up testing.

Type ServerURL
type ServerURL string

ServerURL is the base URL of the Pebble management API (e.g. "https://localhost:15000"). Root and intermediate certs are fetched from the standard Pebble management API paths (/roots/0 and /intermediates/0).

Methods
func (p ServerURL) Enabled() bool
func (p ServerURL) IntermediateURL() string
func (p ServerURL) RootURL() string
Type T
type T struct {
	// contains filtered or unexported fields
}

T manages a pebble instance for testing purposes.

Functions
func New(binary string, opts ...ServerOption) *T

New creates a new Pebble instance. The supplied configFile will be used to configure the pebble instance. The server is not started by New.

Methods
func (p *T) EnsureStopped(ctx context.Context, waitFor time.Duration) error

EnsureStopped ensures that the pebble instance is stopped.

func (p *T) PID() int

PID returns the process ID of the pebble instance.

func (p *T) Start(ctx context.Context, dir, cfg string, forward io.WriteCloser) error

Start the pebble instance with its output forwarded to the supplied writer.

func (p *T) WaitForIssuedCertificateSerial(ctx context.Context) (string, error)

WaitForIssuedCertificateSerial waits until a certificate is issued and returns its serial number.

func (p *T) WaitForOrderAuthorized(ctx context.Context) (string, error)

WaitForOrderAuthorized waits until an order is authorized and returns its order ID.

func (p *T) WaitForReady(ctx context.Context) error

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Address           string
	ManagementAddress string
	HTTPPort          int
	TLSPort           int
	Certificate       []byte
	CertificateFile   string
	CAFile            string
	TestCertBase      string
	RootCertURL       string
	// contains filtered or unexported fields
}

Config represents the configuration for a pebble instance that's relevant to using it for testing clients.

func NewConfig

func NewConfig(opt ...ConfigOption) Config

NewConfig creates a new Config instance with default values.

func (Config) CA

func (pc Config) CA() *x509.CertPool

CA returns a CertPool containing the root pebble CA certificate. Use it when configuring clients to connect to the pebble instance.

func (Config) CARootsURL

func (pc Config) CARootsURL(id int) string

CARootsURL returns the URL from which the pebble root CA certificate can be retrieved, use 0 as the id.

func (*Config) CreateCertsAndUpdateConfig

func (pc *Config) CreateCertsAndUpdateConfig(ctx context.Context, outputDir string) (string, error)

CreateCertsAndUpdateConfig uses minica to create a self-signed certificate for use with the pebble instance and applies any other config customizations requested by any ConfigOptions. The generated certificate and key are placed in outputDir. It returns the path to the possibly updated configuration file to be used when starting pebble. Use minica to create a self-signed certificate for the domain as per:

	  minica -ca-cert pebble.minica.pem \
          -ca-key pebble.minica.key.pem \
          -domains localhost,pebble \
          -ip-addresses 127.0.0.1

func (Config) DirectoryURL

func (pc Config) DirectoryURL() string

DirectoryURL returns the ACME service 'directory' URL.

func (Config) GetIssuingCA

func (pc Config) GetIssuingCA(ctx context.Context, id int) (*x509.CertPool, error)

IssuingCA returns a CertPool containing the issuing CA certificate used by pebble to sign issued certificates.

func (Config) GetIssuingCert

func (pc Config) GetIssuingCert(ctx context.Context, id int) ([]byte, error)

GetIssuingCert retrieves the pebble certificate, including intermediates, used to sign issued certificates.

func (Config) PossibleValidityPeriods

func (pc Config) PossibleValidityPeriods() []time.Duration

PossibleValidityPeriods returns the validity periods specified across all defined profiles in the pebble config.

func (Config) ValidateCertificate

func (pc Config) ValidateCertificate(ctx context.Context, cert *x509.Certificate, intermediates *x509.CertPool) error

type ConfigOption

type ConfigOption func(*configOption)

ConfigOption represents an option for configuring a new Config instance.

func WithAlternatePorts

func WithAlternatePorts(managementPort, serverPort int) ConfigOption

WithAlternatePorts returns a ConfigOption that sets alternate ports for the pebble management and server ports.

func WithValidityPeriod

func WithValidityPeriod(secs int) ConfigOption

WithValidityPeriod returns a ConfigOption that sets the validity period for all issued certificates by modifying the value in all pebble profiles.

type ServerOption

type ServerOption func(*serverOptions)

ServerOption represents a option for configuring a new Pebble instance.

func WithNoSleep

func WithNoSleep() ServerOption

WithNoSleep returns a ServerOption that disables sleeps in pebble to speed up testing.

type ServerURL

type ServerURL string

ServerURL is the base URL of the Pebble management API (e.g. "https://localhost:15000"). Root and intermediate certs are fetched from the standard Pebble management API paths (/roots/0 and /intermediates/0).

func (ServerURL) Enabled

func (p ServerURL) Enabled() bool

func (ServerURL) IntermediateURL

func (p ServerURL) IntermediateURL() string

func (ServerURL) RootURL

func (p ServerURL) RootURL() string

type T

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

T manages a pebble instance for testing purposes.

func New

func New(binary string, opts ...ServerOption) *T

New creates a new Pebble instance. The supplied configFile will be used to configure the pebble instance. The server is not started by New.

func (*T) EnsureStopped

func (p *T) EnsureStopped(ctx context.Context, waitFor time.Duration) error

EnsureStopped ensures that the pebble instance is stopped.

func (*T) PID

func (p *T) PID() int

PID returns the process ID of the pebble instance.

func (*T) Start

func (p *T) Start(ctx context.Context, dir, cfg string, forward io.WriteCloser) error

Start the pebble instance with its output forwarded to the supplied writer.

func (*T) WaitForIssuedCertificateSerial

func (p *T) WaitForIssuedCertificateSerial(ctx context.Context) (string, error)

WaitForIssuedCertificateSerial waits until a certificate is issued and returns its serial number.

func (*T) WaitForOrderAuthorized

func (p *T) WaitForOrderAuthorized(ctx context.Context) (string, error)

WaitForOrderAuthorized waits until an order is authorized and returns its order ID.

func (*T) WaitForReady

func (p *T) WaitForReady(ctx context.Context) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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