tls

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2023 License: Apache-2.0 Imports: 18 Imported by: 3

Documentation

Overview

Package tls provides TLS utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Certificate

func Certificate(host ...string) (tls.Certificate, *x509.CertPool, error)

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

func GenTLSConfig(addr ...string) (*tls.Config, error)

GenTLSConfig creates a self signed certificate and returns it in a TSL config.

func LoadTLSConfig

func LoadTLSConfig(certFile, keyFile string) (*tls.Config, error)

LoadTLSConfig loads a TLS config from certificate files.

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

func (t Config) MarshalJSON() ([]byte, error)

MarshalJSON satisfies the json.Marshaler interface.

func (Config) MarshalYAML

func (t Config) MarshalYAML() (interface{}, error)

MarshalYAML satisfies the yaml.Marshaler interface.

func (*Config) UnmarshalJSON

func (t *Config) UnmarshalJSON(b []byte) (err error)

UnmarshalJSON satisfies the json.Unmarshaler interface.

func (*Config) UnmarshalYAML

func (t *Config) UnmarshalYAML(u func(interface{}) error) (err error)

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.

Jump to

Keyboard shortcuts

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