tls

package
v0.87.1 Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2026 License: Apache-2.0 Imports: 17 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrCustomProfileNil is returned when a custom TLS profile is specified but the Custom field is nil.
	ErrCustomProfileNil = errors.New("custom TLS profile specified but Custom field is nil")

	// ErrUnknownProfileType is returned when the profile type is not recognized.
	ErrUnknownProfileType = errors.New("unknown TLS profile type")

	// ErrNoSupportedCiphers is returned when none of the profile ciphers is supported.
	ErrNoSupportedCiphers = errors.New("TLS profile specifies ciphers but none are supported")

	// ErrNoSupportedCurves is returned when none of the profile curves is supported.
	ErrNoSupportedCurves = errors.New("TLS profile specifies curves but none are supported")
)
View Source
var TLSProfiles = map[TLSProfileType]*TLSProfileSpec{
	TLSProfileOldType: {
		Ciphers: []string{
			"TLS_AES_128_GCM_SHA256",
			"TLS_AES_256_GCM_SHA384",
			"TLS_CHACHA20_POLY1305_SHA256",
			"ECDHE-ECDSA-AES128-GCM-SHA256",
			"ECDHE-RSA-AES128-GCM-SHA256",
			"ECDHE-ECDSA-AES256-GCM-SHA384",
			"ECDHE-RSA-AES256-GCM-SHA384",
			"ECDHE-ECDSA-CHACHA20-POLY1305",
			"ECDHE-RSA-CHACHA20-POLY1305",
			"ECDHE-ECDSA-AES128-SHA256",
			"ECDHE-RSA-AES128-SHA256",
			"ECDHE-ECDSA-AES128-SHA",
			"ECDHE-RSA-AES128-SHA",
			"ECDHE-ECDSA-AES256-SHA",
			"ECDHE-RSA-AES256-SHA",
			"AES128-GCM-SHA256",
			"AES256-GCM-SHA384",
			"AES128-SHA256",
			"AES128-SHA",
			"AES256-SHA",
			"DES-CBC3-SHA",
		},
		MinTLSVersion: VersionTLS10,
	},
	TLSProfileIntermediateType: {
		Ciphers: []string{
			"TLS_AES_128_GCM_SHA256",
			"TLS_AES_256_GCM_SHA384",
			"TLS_CHACHA20_POLY1305_SHA256",
			"ECDHE-ECDSA-AES128-GCM-SHA256",
			"ECDHE-RSA-AES128-GCM-SHA256",
			"ECDHE-ECDSA-AES256-GCM-SHA384",
			"ECDHE-RSA-AES256-GCM-SHA384",
			"ECDHE-ECDSA-CHACHA20-POLY1305",
			"ECDHE-RSA-CHACHA20-POLY1305",
		},
		MinTLSVersion: VersionTLS12,
	},
	TLSProfileModernType: {
		Ciphers: []string{
			"TLS_AES_128_GCM_SHA256",
			"TLS_AES_256_GCM_SHA384",
			"TLS_CHACHA20_POLY1305_SHA256",
		},
		MinTLSVersion: VersionTLS13,
	},
}

TLSProfiles contains the predefined TLS profile specifications. Based on version 5.7 of the Mozilla Server Side TLS configuration guidelines. See: https://ssl-config.mozilla.org/guidelines/5.7.json

Functions

This section is empty.

Types

type SecurityProfileWatcher

type SecurityProfileWatcher struct {
	client.Client

	// InitialTLSProfileSpec is the TLS profile spec that was configured when the operator started.
	InitialTLSProfileSpec TLSProfileSpec

	// OnProfileChange is called when the TLS profile changes.
	OnProfileChange func(ctx context.Context, oldTLSProfileSpec, newTLSProfileSpec TLSProfileSpec)
}

SecurityProfileWatcher watches the APIServer object for TLS profile changes and triggers a callback when the profile changes.

func (*SecurityProfileWatcher) Reconcile

func (r *SecurityProfileWatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile watches for changes to the APIServer TLS profile.

func (*SecurityProfileWatcher) SetupWithManager

func (r *SecurityProfileWatcher) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type TLSProfileSpec

type TLSProfileSpec struct {
	Ciphers       []string           `json:"ciphers"`
	MinTLSVersion TLSProtocolVersion `json:"minTLSVersion"`
	// Curves lists the allowed TLS key exchange groups; empty means Go
	// defaults (post-quantum X25519MLKEM768 included).
	Curves []string `json:"curves,omitempty"`
}

TLSProfileSpec is the desired behavior of a TLSSecurityProfile.

func FetchAPIServerTLSProfile

func FetchAPIServerTLSProfile(ctx context.Context, k8sClient client.Client) (TLSProfileSpec, error)

FetchAPIServerTLSProfile fetches the TLS profile spec from the cluster's APIServer resource.

func GetTLSProfileSpec

func GetTLSProfileSpec(profile *tlsSecurityProfile) (TLSProfileSpec, error)

GetTLSProfileSpec returns a TLSProfileSpec for the given profile. If no profile is configured, the default Intermediate profile is returned; unknown profile types are an error.

type TLSProfileType

type TLSProfileType string

TLSProfileType defines a TLS security profile type.

const (
	TLSProfileOldType          TLSProfileType = "Old"
	TLSProfileIntermediateType TLSProfileType = "Intermediate"
	TLSProfileModernType       TLSProfileType = "Modern"
	TLSProfileCustomType       TLSProfileType = "Custom"
)

type TLSProtocolVersion

type TLSProtocolVersion string

TLSProtocolVersion is a way to specify the protocol version used for TLS connections.

const (
	VersionTLS10 TLSProtocolVersion = "VersionTLS10"
	VersionTLS11 TLSProtocolVersion = "VersionTLS11"
	VersionTLS12 TLSProtocolVersion = "VersionTLS12"
	VersionTLS13 TLSProtocolVersion = "VersionTLS13"
)

type UnsupportedEntries

type UnsupportedEntries struct {
	Ciphers []string
	Curves  []string
	// UnenforceableCiphers lists TLS 1.3 cipher suites that Go always
	// offers even though the profile excludes them.
	UnenforceableCiphers []string
}

UnsupportedEntries lists profile entries that were dropped because Go does not support them, and restrictions that Go cannot enforce.

func NewTLSConfigFromProfile

func NewTLSConfigFromProfile(profile TLSProfileSpec) (func(*tls.Config), UnsupportedEntries, error)

NewTLSConfigFromProfile returns a function that configures a tls.Config based on the provided TLSProfileSpec, along with any profile entries that could not be honored. It returns an error when the profile cannot be honored at all, instead of falling back to Go defaults that may exceed it.

func (UnsupportedEntries) IsEmpty

func (u UnsupportedEntries) IsEmpty() bool

IsEmpty returns true when every profile entry is supported and enforceable.

func (UnsupportedEntries) Message

func (u UnsupportedEntries) Message() string

Message returns a human-readable description of the entries.

Jump to

Keyboard shortcuts

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