clienttls

package
v0.66.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package clienttls turns declarative client-side TLS material — PEM from a file path or a base64-encoded value — into a *tls.Config. It is the shared loader behind the httpclient TLS options and the Redis cache client, and it never disables certificate verification: no InsecureSkipVerify escape hatch exists here.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(prefix string, m *Material) (*tls.Config, error)

Build loads m into a *tls.Config. prefix names the consumer's error namespace, as in secretfile.LoadPEM. Material-free input is legal and yields a verifying config over the system roots.

func HasAnyMaterial

func HasAnyMaterial(m *Material) bool

HasAnyMaterial reports whether m names any PEM piece. ServerName and MinVersion are deliberately excluded: they tune a connection, they do not stage material for one.

func HasClientCert

func HasClientCert(m *Material) bool

HasClientCert reports whether any cert or key field is set. A CA-only Material is server authentication alone: it presents no client certificate.

Types

type Material

type Material struct {
	CertFile   string
	CertValue  string
	KeyFile    string
	KeyValue   string
	CAFile     string
	CAValue    string
	ServerName string
	MinVersion string
}

Material is the client-side TLS material: three PEM pieces, each from a file path or a base64-encoded value, plus the SNI override and the version floor. Every field is a comparable type so the structs embedding it stay comparable.

type Violation

type Violation struct {
	Field   string
	Message string
}

Violation names the Material field (relative key such as "cafile") that breaks a structural rule, with the message to report. Field is relative on purpose: each consumer owns its own key namespace and prefixes it.

func ValidateMaterial

func ValidateMaterial(m *Material, enabled bool) *Violation

ValidateMaterial applies the structural rules that need no filesystem: material staged under a disabled block, a piece configured from two sources, a half client-certificate pair, and the min-version enum. It returns nil when the shape is valid — enabled with no material at all is valid, and yields a config verifying against the system roots.

Reading and parsing the PEM happens later, in Build.

Jump to

Keyboard shortcuts

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