tlspolicy

package
v1.15.4 Latest Latest
Warning

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

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

Documentation

Overview

The TLS parsing helpers in this file mirror k8s.io/component-base/cli/flag (TLSVersion, TLSCipherSuites, InsecureTLSCiphers, TLSCurvePreferences, and related functions). SPIRE does not import that package directly because component-base does not provide compatibility guarantees for its APIs for non k8s workloads.

Package tlspolicy provides for configuration and enforcement of policies relating to TLS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyPolicy

func ApplyPolicy(config *tls.Config, policy Policy, opts ...ApplyOption) error

ApplyPolicy applies policy to config. RequirePQKEM is always honored when set. TLSConfig fields are applied only when WithServerTLSConfig() is passed. TLSConfig is applied before RequirePQKEM so PQ settings take precedence for backward compatibility.

func DefaultTLSVersion added in v1.15.4

func DefaultTLSVersion() uint16

DefaultTLSVersion defines the default TLS Version.

func InsecureTLSCiphers added in v1.15.4

func InsecureTLSCiphers() map[string]uint16

InsecureTLSCiphers returns the cipher suites implemented by crypto/tls which have security issues.

func LogPolicy

func LogPolicy(policy Policy, logger hclog.Logger)

LogPolicy logs an informational message reporting the configured policy, aiding administrators to determine what policy options have been successfully enabled.

func TLSCipherSuites added in v1.15.4

func TLSCipherSuites(cipherNames []string) ([]uint16, error)

TLSCipherSuites returns a list of cipher suite IDs from the cipher suite names passed.

func TLSCurvePreferences added in v1.15.4

func TLSCurvePreferences(curveIDs []int32) ([]tls.CurveID, error)

TLSCurvePreferences returns a list of Go's crypto/tls CurveID values from the ids passed. The supported values depend on the Go version used. See https://pkg.go.dev/crypto/tls#CurveID for values supported for each Go version.

func TLSVersion added in v1.15.4

func TLSVersion(versionName string) (uint16, error)

TLSVersion returns the TLS Version ID for the version name passed.

Types

type ApplyOption added in v1.15.4

type ApplyOption func(*tls.Config, Policy) error

ApplyOption selects optional parts of Policy to apply.

func WithServerTLSConfig added in v1.15.4

func WithServerTLSConfig() ApplyOption

WithServerTLSConfig applies policy.TLSCfg (min_tls_version, cipher_suites, curve_preferences) to the tls.Config.

Intended for terminating TCP listeners only: the server controls what it accepts. Outbound clients should negotiate with peers instead; imposing these settings on a client can break handshakes with external servers that do not support the configured parameters.

type ParsedTLSConfig added in v1.15.4

type ParsedTLSConfig struct {
	MinTLSVersion    uint16
	CipherSuites     []uint16
	CurvePreferences []tls.CurveID
}

ParsedTLSConfig holds tls_config values parsed once at startup.

func ParseTLSConfig added in v1.15.4

func ParseTLSConfig(cfg *TLSConfig, logger hclog.Logger) (*ParsedTLSConfig, error)

ParseTLSConfig parses tls_config strings into typed TLS settings.

type Policy

type Policy struct {
	// RequirePQKEM determines if a post-quantum-safe KEM should be required for
	// TLS connections. When enabled it takes precedence over TLSConfig curve and
	// minimum version settings.
	RequirePQKEM bool

	// TLSCfg holds parsed tls_config settings. Populated by NewPolicy or ParseTLSConfig.
	TLSCfg *ParsedTLSConfig
}

Policy describes policy options to be applied to a TLS configuration.

A zero-initialised Policy provides reasonable defaults.

func NewPolicy added in v1.15.4

func NewPolicy(requirePQKEM bool, cfg *TLSConfig, logger hclog.Logger) (Policy, error)

NewPolicy builds a Policy and parses tls_config once at startup.

type TLSConfig added in v1.15.4

type TLSConfig struct {
	CipherSuites     []string `hcl:"cipher_suites"`
	CurvePreferences []string `hcl:"curve_preferences"`
	MinTLSVersion    string   `hcl:"min_tls_version"`
}

TLSConfig describes TLS configuration settings for terminating endpoints. Unset fields are not applied.

Jump to

Keyboard shortcuts

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