Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type TlsCertificateLoader ¶
type TlsCertificateLoader struct {
// contains filtered or unexported fields
}
TLS certificate loader
func NewTlsCertificateLoader ¶
func NewTlsCertificateLoader(config TlsCertificateLoaderConfig) (*TlsCertificateLoader, error)
Creates a new instance of TlsCertificateLoader Also loads the key pair for the first time
Takes the configuration as the only parameter ¶
Returns an error as the seconds return value if an error occurs loading the key pair for the first time In this case, no instance is created, and nil is returned instead as the first return value.
Important: If succeeded, this function starts a new co-routine to periodically reload the key pair. If you stop that co-routine, call the Close() function
func (*TlsCertificateLoader) Close ¶
func (loader *TlsCertificateLoader) Close()
Closes the loader, stopping its co-routine
func (*TlsCertificateLoader) GetCertificate ¶
func (loader *TlsCertificateLoader) GetCertificate(_ *tls.ClientHelloInfo) (*tls.Certificate, error)
Obtains the current loaded TLS key pair The client info parameter is ignored This function will never return an error
func (*TlsCertificateLoader) IsClosed ¶
func (loader *TlsCertificateLoader) IsClosed() bool
Checks if the loader is closed A closed loader is not checking for changes anymore
type TlsCertificateLoaderConfig ¶
type TlsCertificateLoaderConfig struct {
// Path to the X.509 certificate chain file
CertificatePath string
// Path to the private key file
KeyPath string
// Period to check to reload the certificate and key
CheckReloadPeriod time.Duration
// Function to call when key pair is reloaded
OnReload func()
// Function to call when an error happens reloading the key pair
OnError func(err error)
}
Configuration for TLS certificate loader