pinned

package
v0.9.2 Latest Latest
Warning

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

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

Documentation

Overview

Package pinned holds the small trust primitives shared by every reverse-dialed client: CA fingerprint pinning and key plus CSR generation. It imports no Docker, exec or build code so a minimal client can link it alone.

Index

Constants

This section is empty.

Variables

View Source
var ErrMismatch = errors.New("agent: control plane CA does not match the pinned fingerprint")

ErrMismatch means the control plane's CA does not match the pinned fingerprint.

Functions

func CheckCA

func CheckCA(caPEM []byte, fingerprint string) error

CheckCA compares a CA PEM against a pinned fingerprint in constant time.

func EnrollTLSConfig

func EnrollTLSConfig(caFingerprint string) *tls.Config

EnrollTLSConfig builds the enrollment TLS config. Go's own verification is skipped because no root exists yet; with a pin, VerifyChain replaces it.

func Fingerprint

func Fingerprint(der []byte) string

Fingerprint returns the hex SHA-256 of a DER-encoded certificate.

func FingerprintPEM

func FingerprintPEM(certPEM []byte) (string, error)

FingerprintPEM returns the fingerprint of the first certificate in certPEM.

func NewKeyAndCSR

func NewKeyAndCSR(commonName string) (keyPEM, csrDER []byte, err error)

NewKeyAndCSR generates an ed25519 key and a CSR for it. The key stays with the caller.

func Normalize

func Normalize(fp string) string

Normalize lowercases a fingerprint and drops colons and spaces.

func SessionTLSConfig

func SessionTLSConfig(caPEM, certPEM, keyPEM []byte) (*tls.Config, error)

SessionTLSConfig builds the long-lived session TLS config from the CA the agent received at enrollment and its own client certificate.

func VerifyChain

func VerifyChain(chain []*x509.Certificate, caFingerprint string) error

VerifyChain accepts the connection only if the chain includes the pinned CA and the leaf is a valid server certificate signed by it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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