servingcert

package
v0.8.0-alpha.2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Overview

Package servingcert keeps a self-signed CA and a serving cert for an in-cluster Service in a Secret, and renews them.

Index

Constants

View Source
const (
	// CAKey is the Secret key holding the PEM CA.
	CAKey = "ca"
	// CAKeyKey is the Secret key holding the PEM private key of the CA.
	CAKeyKey = "ca.key"
	// CertKey is the Secret key holding the PEM serving cert.
	CertKey = "tls.crt"
	// KeyKey is the Secret key holding the PEM private key of the serving cert.
	KeyKey = "tls.key"
	// PreviousCAKey is the Secret key holding the CA that was replaced last.
	PreviousCAKey = "ca.previous"
	// PreviousCAUntilAnnotation is the time until which PreviousCAKey is trusted.
	PreviousCAUntilAnnotation = "servingcert.oam.dev/previous-ca-until"
)

Variables

This section is empty.

Functions

func Check

func Check(data map[string][]byte, hosts []string, validUntil time.Time) error

Check verifies a serving key pair against its CA, hosts, and time.

func Covers

func Covers(trusted, bundle []byte) bool

Covers reports whether every certificate in bundle is also in trusted.

func Generate

func Generate(hosts []string, notBefore, notAfter time.Time) (map[string][]byte, error)

Generate makes a self-signed CA and a serving cert for hosts.

func WriteFileIfChanged

func WriteFileIfChanged(path string, data []byte) (bool, error)

WriteFileIfChanged writes data with owner-only permissions unless unchanged.

Types

type Result

type Result struct {
	Cert, Key []byte
	CABundle  []byte
}

Result is what EnsureSecret returns.

func EnsureSecret

func EnsureSecret(ctx context.Context, c client.Client, namespace, name string, svc Service) (*Result, error)

EnsureSecret creates, renews, or reuses the serving cert Secret.

type Service

type Service struct {
	Namespace string
	Name      string
}

Service is the Service a serving cert is for.

func (Service) Hosts

func (s Service) Hosts() []string

Hosts are the names put in a generated cert.

func (Service) RequiredHosts

func (s Service) RequiredHosts() []string

RequiredHosts are the names that clients dial. The old certgen Job used these names, so its Secret remains valid after an upgrade.

Jump to

Keyboard shortcuts

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