certman

package
v1.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: MIT Imports: 9 Imported by: 3

Documentation

Overview

Package certman provides live reloading of the certificate and key files used by the standard library http.Server. It defines a type, certMan, with methods watching and getting the files. Only valid certificate and key pairs are loaded and an optional logger can be passed to certman for logging providing it implements the logger interface.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CertMan

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

A CertMan represents a certificate manager able to watch certificate and key pairs for changes.

func New

func New(logger log.Logger, certFile, keyFile string) (*CertMan, error)

New creates a new certMan. The certFile and the keyFile are both paths to the location of the files. Relative and absolute paths are accepted.

func (*CertMan) GetCertificate

func (cm *CertMan) GetCertificate(hello *tls.ClientHelloInfo) (*tls.Certificate, error)

GetCertificate returns the loaded certificate for use by the GetCertificate field in tls.Config.

func (*CertMan) GetClientCertificate

func (cm *CertMan) GetClientCertificate(hello *tls.CertificateRequestInfo) (*tls.Certificate, error)

GetClientCertificate returns the loaded certificate for use by the GetClientCertificate field in tls.Config.

func (*CertMan) Stop

func (cm *CertMan) Stop()

Stop tells certMan to stop watching for changes to the certificate and key files.

func (*CertMan) Watch

func (cm *CertMan) Watch() error

Watch starts watching for changes to the certificate and key files. On any change the certificate and key are reloaded. If there is an issue the load will fail and the old (if any) certificates and keys will continue to be used.

Jump to

Keyboard shortcuts

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