tls

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: May 7, 2024 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertReloader

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

CertReloader is the struct that parses a certificate/key pair, providing a goroutine safe GetCertificate method to retrieve the parsed content.

The GetCertificate signature is compatible with https://golang.org/pkg/crypto/tls/#Config.GetCertificate and can be used to hot-reload a certificate/key pair.

For hot-reloading the Watch method must be started explicitly.

func NewCertReloader

func NewCertReloader(certPath, keyPath string, interval time.Duration) (*CertReloader, error)

NewCertReloader creates a new CertReloader that loads certs in an interval.

func (*CertReloader) GetCertificate

func (r *CertReloader) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate returns the current valid certificate. The ClientHello message is ignored and is just there to be compatible with https://golang.org/pkg/crypto/tls/#Config.GetCertificate.

func (*CertReloader) Watch

func (r *CertReloader) Watch(ctx context.Context) error

Watch watches the configured certificate and key path and blocks the current goroutine until the scenario context is done or an error occurred during reloading.

Jump to

Keyboard shortcuts

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