Documentation ¶
Overview ¶
Package tls provides TLS utilities.
Index ¶
- func Certificate(host ...string) (tls.Certificate, *x509.CertPool, error)
- func CertificateQuic() (tls.Certificate, error)
- func GenTLSConfig(addr ...string) (*tls.Config, error)
- func LoadTLSConfig(certFile, keyFile string) (*tls.Config, error)
- type ClientAuth
- func (auth ClientAuth) MarshalJSON() ([]byte, error)
- func (auth ClientAuth) MarshalYAML() (interface{}, error)
- func (auth *ClientAuth) Set(s string) error
- func (auth *ClientAuth) String() string
- func (auth *ClientAuth) UnmarshalJSON(b []byte) error
- func (auth *ClientAuth) UnmarshalYAML(u func(interface{}) error) error
- type Config
- type ConfigFiles
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Certificate ¶
Certificate generates a self signed certificate.
func CertificateQuic ¶
func CertificateQuic() (tls.Certificate, error)
CertificateQuic generates a certificate for use with QUIC. NOTE: this is redundant, was just here to test, might remove later, still needs to check if its useful.
func GenTLSConfig ¶
GenTLSConfig creates a self signed certificate and returns it in a TSL config.
Types ¶
type ClientAuth ¶
type ClientAuth struct{ tls.ClientAuthType }
ClientAuth provides a convenience wrapper for tls.ClientAuthType and conversion to and from string format.
Supported string values are:
"none": tls.NoClientCert (default) "request": tls.RequestClientCert "require": tls.RequireAnyClientCert "verify": tls.VerifyClientCertIfGiven "require+verify": tls.RequireAndVerifyClientCert
func (ClientAuth) MarshalJSON ¶
func (auth ClientAuth) MarshalJSON() ([]byte, error)
MarshalJSON satisfies the json.Marshaler interface.
func (ClientAuth) MarshalYAML ¶
func (auth ClientAuth) MarshalYAML() (interface{}, error)
MarshalYAML satisfies the yaml.Marshaler interface.
func (*ClientAuth) Set ¶
func (auth *ClientAuth) Set(s string) error
Set satisfies the flag.Value interface.
func (*ClientAuth) String ¶
func (auth *ClientAuth) String() string
String satisfies the flag.Value interface.
func (*ClientAuth) UnmarshalJSON ¶
func (auth *ClientAuth) UnmarshalJSON(b []byte) error
UnmarshalJSON satisfies the json.Unmarshaler interface.
func (*ClientAuth) UnmarshalYAML ¶
func (auth *ClientAuth) UnmarshalYAML(u func(interface{}) error) error
UnmarshalYAML satisfies the yaml.Unmarshaler interface.
type Config ¶
type Config struct { ConfigFiles *tls.Config }
Config provides JSON and YAML Marshalers and Unmarshalers for loading values into tls.Config.
The JSON and YAML configuration format is provided by the embedded type TLSConfig.
func (Config) MarshalJSON ¶
MarshalJSON satisfies the json.Marshaler interface.
func (Config) MarshalYAML ¶
MarshalYAML satisfies the yaml.Marshaler interface.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON satisfies the json.Unmarshaler interface.
func (*Config) UnmarshalYAML ¶
UnmarshalYAML satisfies the yaml.Unmarshaler interface.
type ConfigFiles ¶
type ConfigFiles struct { RootCAFiles []string `json:"rootCAFiles,omitempty" yaml:"rootCAFiles,omitempty"` //nolint:tagliatelle ClientCAFiles []string `json:"clientCAFiles,omitempty" yaml:"clientCAFiles,omitempty"` //nolint:tagliatelle ClientAuth ClientAuth `json:"clientAuth,omitempty" yaml:"clientAuth,omitempty"` Certificates []struct { CertFile string `json:"certFile" yaml:"certFile"` KeyFile string `json:"keyFile" yaml:"keyFile"` } `json:"certificates,omitempty" yaml:"certificates,omitempty"` }
ConfigFiles contains the configuration for TLS as it appears on the JSON or YAML config. Values parsed from the config are translated and loaded into corresponding fields in tls.Config.