tls

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	EmptyClientConfig   = ClientConfig{}
	EmptyServerConfig   = ServerConfig{}
	EmptyAutoCertConfig = AutoCertConfig{}
)

Functions

func AutocertManagerFromConfig added in v0.36.0

func AutocertManagerFromConfig(c AutoCertConfig) *autocert.Manager

func ConvertClientConfig

func ConvertClientConfig(c ClientConfig) (*tls.Config, error)

func ConvertServerConfig

func ConvertServerConfig(c ServerConfig) (*tls.Config, error)

func CreateAndSaveSelfSignedKeyPair

func CreateAndSaveSelfSignedKeyPair(config SelfSignedConfig, certPath, keyPath string) (*tls.Certificate, *x509.CertPool, error)

func CreateSelfSignedKeyPair

func CreateSelfSignedKeyPair(config SelfSignedConfig) (*tls.Certificate, *x509.CertPool, error)

pulled from inet.af/tcpproxy

func LoadCertPoolFromFile

func LoadCertPoolFromFile(certPoolPath string) (*x509.CertPool, error)

func LoadKeyPairAndCertsFromFile

func LoadKeyPairAndCertsFromFile(path string) (*tls.Certificate, error)

LoadKeyPairAndCertsFromFile From: https://gist.github.com/ukautz/cd118e298bbd8f0a88fc LoadKeyPairAndCertsFromFile reads file, divides into key and certificates

func LoadKeyPairFromFiles

func LoadKeyPairFromFiles(certPath, keyPath string) (*tls.Certificate, error)

func LoadX509CertFromFile

func LoadX509CertFromFile(certPath string) (*x509.Certificate, error)

func SaveTLSCertificateToFiles

func SaveTLSCertificateToFiles(cert *tls.Certificate, certPath, keyPath string) error

Types

type AutoCertConfig

type AutoCertConfig struct {
	CacheDirectory string   `mapstructure:"cache-directory" json:",omitempty"`
	Email          string   `mapstructure:"email" json:",omitempty"`
	AllowedHosts   []string `mapstructure:"allowed-hosts" json:",omitempty"`
	DirectoryURL   string   `mapstructure:"directory-url" json:",omitempty"`
}

func (AutoCertConfig) IsEmpty

func (c AutoCertConfig) IsEmpty() bool

type ClientConfig

type ClientConfig struct {
	RootCAFile         string `mapstructure:"root-ca-file" json:",omitempty"`
	Certificate        string `mapstructure:"cert" json:",omitempty"`
	Key                string `mapstructure:"key" json:",omitempty"`
	InsecureSkipVerify bool   `mapstructure:"insecure-skip-verify"`
}

func (ClientConfig) IsEmpty

func (c ClientConfig) IsEmpty() bool

type SelfSignedConfig

type SelfSignedConfig struct {
	Subject     pkix.Name
	DNSNames    []string
	IPAddresses []net.IP
	NotBefore   time.Time
	NotAfter    time.Time
	IsCA        bool
}

type ServerConfig

type ServerConfig struct {
	ServerName string `mapstructure:"server-name"`

	AutoCertConfig AutoCertConfig `mapstructure:"auto-cert-config"`

	SinglePEMFile string `mapstructure:"single-pem-file" json:",omitempty"`
	Certificate   string `mapstructure:"cert" json:",omitempty"`
	Key           string `mapstructure:"key" json:",omitempty"`

	FileWaitInterval int `mapstructure:"file-wait-interval" json:",omitempty"`
	FileWaitMax      int `mapstructure:"file-wait-max" json:",omitempty"`

	ClientAuthType string `mapstructure:"client-auth-type" json:",omitempty"`
	ClientCAFile   string `mapstructure:"client-ca-file" json:",omitempty"`

	NextProtos []string `mapstructure:"next-protos"`
}

func (ServerConfig) IsEmpty

func (s ServerConfig) IsEmpty() bool

Jump to

Keyboard shortcuts

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