credentials

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: Apache-2.0 Imports: 9 Imported by: 0 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

Overview

Package credentials mints the throwaway certificates the local examples run on.

It stands in for the thing a real deployment already has: an internal CA under the PKI profile, a SPIFFE issuer under the SPIFFE one. Neither is something purser provides — cert-manager and SPIRE do that, and the Kubernetes manifests under examples/k8s use them. This exists so the local cells need no infrastructure at all.

Three identities are minted, not two. The third is the one that must be turned away: under the PKI profile it carries a different organizational unit, under the SPIFFE profile a different SPIFFE ID. A demonstration where every credential works shows only that TLS is on.

Everything it writes is disposable and expires in an hour. Nothing here belongs anywhere near a real deployment, and nothing it writes should be committed.

Index

Constants

View Source
const (
	ServerDir       = "server"
	ClientDir       = "client"
	UnauthorizedDir = "unauthorized"
)

Names of the per-identity directories written under Dir.

View Source
const (
	PKICertFile = "cert.pem"
	PKIKeyFile  = "key.pem"
	PKICAFile   = "ca.pem"
)

File names under the PKI profile. The SPIFFE profile instead uses mtls.GKECertFile, mtls.GKEKeyFile and mtls.GKEBundleFile, so a -spiffe-dir pointed at one of these directories is laid out exactly like GKE's managed workload identity mount.

Variables

This section is empty.

Functions

This section is empty.

Types

type Identity

type Identity struct {
	// Name is the directory under Dir: ServerDir, ClientDir or
	// UnauthorizedDir.
	Name string
	// Dir is the absolute directory holding the three PEM files.
	Dir string
	// Subject is the identity a purser server will report for a peer
	// presenting this credential — the DNS SAN under the PKI profile,
	// the SPIFFE ID under the SPIFFE one.
	Subject string
}

Identity is one minted credential and where it landed.

type PKIOptions

type PKIOptions struct {
	// Dir is the directory to write into. Required.
	Dir string
	// ServerHost is the host the server certificate is valid for. An
	// IP lands in an IP SAN, a name in a DNS SAN. Default "127.0.0.1".
	ServerHost string
	// ClientName is the DNS SAN on the client certificate, which the
	// san_dns subject source reads as the identity. Default
	// "hello-client.local".
	ClientName string
	// ClientOU is the organizational unit on the client certificate,
	// for -pki-admit-ou. Default "platform".
	ClientOU string
	// UnauthorizedOU is the organizational unit on the third
	// certificate, the one -pki-admit-ou must reject. Default
	// "interns".
	UnauthorizedOU string
}

PKIOptions configures MintPKI. Zero fields take the defaults named in each comment.

type SPIFFEOptions

type SPIFFEOptions struct {
	// Dir is the directory to write into. Required.
	Dir string
	// TrustDomain is the domain to mint SVIDs in. Default
	// "example.org".
	TrustDomain string
	// ServerPath, ClientPath and UnauthorizedPath are the SVID paths.
	// Defaults "/ns/default/sa/hello-server", ".../hello-client" and
	// ".../intruder".
	ServerPath       string
	ClientPath       string
	UnauthorizedPath string
}

SPIFFEOptions configures MintSPIFFE. Zero fields take the defaults named in each comment.

type Set

type Set struct {
	Server       Identity
	Client       Identity
	Unauthorized Identity
}

Set is the result of a mint: the three identities, in a fixed order.

func MintPKI

func MintPKI(opts PKIOptions) (Set, error)

MintPKI writes a CA and three standard-CA certificates under opts.Dir.

func MintSPIFFE

func MintSPIFFE(opts SPIFFEOptions) (Set, error)

MintSPIFFE writes a CA and three X509-SVIDs under opts.Dir, each directory laid out like GKE's managed workload identity mount.

func (Set) All

func (s Set) All() []Identity

All returns the identities in server, client, unauthorized order.

Jump to

Keyboard shortcuts

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