tlsconf

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package tlsconf turns the shared TLS file options into a tls.Config.

The four keys are ca_file, cert_file, key_file and tls_server_name. Every TLS protocol uses them the same way. ca_file replaces the system roots. cert_file and key_file are sent together when the server asks for a client certificate. The files are read when Apply runs, and the file bytes are not kept after the config is built.

Index

Constants

This section is empty.

Variables

View Source
var Keys = []string{"ca_file", "cert_file", "key_file", "tls_server_name"}

Keys are the option names, in the order a "TLS is off" error reports them.

Functions

func LiveFiles

func LiveFiles(opts map[string]string, prefix string)

LiveFiles copies VEGALOAD_TEST_<NAME>_CA_FILE, _CERT_FILE, _KEY_FILE and _TLS_SERVER_NAME into opts when they are set. prefix is the part before those suffixes, such as VEGALOAD_TEST_REDIS.

Types

type Files

type Files struct {
	CAFile     string
	CertFile   string
	KeyFile    string
	ServerName string
}

Files is the four options. Empty strings mean the option was not set.

func FromOptions

func FromOptions(opts map[string]string) Files

FromOptions reads the four keys. A missing key and an empty value are the same.

func (Files) Apply

func (f Files) Apply(cfg *tls.Config, insecure, tlsOn bool) error

Apply checks the options and fills cfg. tlsOn is false when the connection is plain text. insecure is true when the certificate will not be checked (-insecure, skip-verify, or a mode that skips verification). cfg must be a config no other goroutine is using. A nil cfg is only valid when nothing is set, or when TLS is off and Apply is reporting that.

On success the PEM bytes are discarded. cfg.RootCAs, when set, is only the certificates from ca_file.

func (Files) Set

func (f Files) Set() bool

Set reports whether any of the four options has a value.

Directories

Path Synopsis
Package tlstest builds a short-lived CA, server certificate and client certificate for tests.
Package tlstest builds a short-lived CA, server certificate and client certificate for tests.

Jump to

Keyboard shortcuts

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