tls

package module
v0.0.0-...-fc4206c Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package tls provides config and flags for building TLS configurations for servers and clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CAConfig

type CAConfig struct {
	Certificate string
}

CAConfig represents a CA certificate.

func (CAConfig) Load

func (f CAConfig) Load(_ context.Context, fileReader FileReader) ([]*x509.Certificate, error)

Load loads the CA certificates. If fileReader is nil, this uses ioutil.ReadFile.

type CertConfig

type CertConfig struct {
	Certificate string
	Key         string
}

CertConfig represent a TLS certificate and its key.

func (CertConfig) Load

func (f CertConfig) Load(_ context.Context, fileReader FileReader) (*tls.Certificate, error)

Load loads the certificate. If fileReader is nil, this uses ioutil.ReadFile.

type Config

type Config struct {
	Store      string
	ClientCert CertConfig
	ClientCA   CAConfig
	ServerCert CertConfig
	ServerCA   CAConfig
}

Config is the configuration for client and server TLS.

func (Config) BuildClientConfig

func (c Config) BuildClientConfig(ctx context.Context) (*tls.Config, error)

BuildClientConfig builds a TLS config suitable for use by clients.

func (Config) BuildServerConfig

func (c Config) BuildServerConfig(ctx context.Context) (*tls.Config, error)

BuildServerConfig builds a TLS config suitable for use by servers.

func (*Config) Flags

func (c *Config) Flags(prefix string) *pflag.FlagSet

Flags returns a flagset that can be added to the command line.

type FileReader

type FileReader interface {
	ReadFile(filename string) ([]byte, error)
}

FileReader reads a file and returns its bytes.

Jump to

Keyboard shortcuts

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