certs

package
v0.0.0-...-1a5dccc Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrAlreadyRunning = errors.New("already running")
)

Functions

func FilePairName

func FilePairName(file string) string

func RemoveSubdirectories

func RemoveSubdirectories(dirs []string) ([]string, error)

func WildcardFor

func WildcardFor(name string) string

Types

type Cache

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

func NewCache

func NewCache(log Logger) *Cache

func (*Cache) Get

func (c *Cache) Get(name string) *Cert

func (*Cache) GetSNI

func (c *Cache) GetSNI(dnsName string) *Cert

func (*Cache) Len

func (c *Cache) Len() int

func (*Cache) PopModified

func (c *Cache) PopModified() []string

func (*Cache) Reload

func (c *Cache) Reload(name string) (bool, error)

func (*Cache) Set

func (c *Cache) Set(certs ...*Cert)

func (*Cache) SetModified

func (c *Cache) SetModified(file string, mod time.Time)

type Cert

type Cert struct {
	Name     string
	CertFile File
	KeyFile  File
	Loaded   time.Time
	tls.Certificate
}

func LoadCertPair

func LoadCertPair(name string, mod time.Time) (*Cert, error)

func LoadDirectoryCerts

func LoadDirectoryCerts(ctx context.Context, dir string) ([]*Cert, error)

func (*Cert) DNSNames

func (c *Cert) DNSNames() []string

func (*Cert) File

func (c *Cert) File(ft FileType) *File

func (*Cert) Reload

func (c *Cert) Reload() error

type File

type File struct {
	Path string
	Mod  time.Time
}

type FileType

type FileType string
const (
	FileTypeUnknown FileType = ""
	FileTypeCert    FileType = "crt"
	FileTypeKey     FileType = "key"
)

func FilePairNameAndType

func FilePairNameAndType(file string) (string, FileType)

type Logger

type Logger interface {
	logger.OutputReceiver
	logger.ErrorOutputReceiver
}

type Reloader

type Reloader struct {
	Lock           sync.Mutex
	Log            Logger
	Dirs           []string
	ReloadInterval time.Duration
	Watch          bool
	// contains filtered or unexported fields
}

func NewReloader

func NewReloader(ctx context.Context, opts ...ReloaderOption) (*Reloader, error)

func (*Reloader) GetCertificate

func (r *Reloader) GetCertificate(helo *tls.ClientHelloInfo) (*tls.Certificate, error)

func (*Reloader) Initialize

func (r *Reloader) Initialize(ctx context.Context) error

func (*Reloader) Start

func (r *Reloader) Start(ctx context.Context) error

func (*Reloader) Stop

func (r *Reloader) Stop() error

type ReloaderOption

type ReloaderOption func(*Reloader)

func OptReloaderDirs

func OptReloaderDirs(dirs ...string) ReloaderOption

func OptReloaderInterval

func OptReloaderInterval(inv time.Duration) ReloaderOption

func OptReloaderLogger

func OptReloaderLogger(log Logger) ReloaderOption

func OptReloaderWatch

func OptReloaderWatch(watch bool) ReloaderOption

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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