Documentation
¶
Overview ¶
Package profile turns example command-line flags into the matched pair purser hands out: a *tls.Config and, on the server side, the authenticator that understands the connections it admits.
Both mTLS profiles are wired here, in one place, so the difference between them is a diff rather than two files a reader has to hold in their head at once. The server and client binaries are then identical across profiles: they take a config, listen or dial, and never learn which profile they are running.
Nothing here is part of purser's exported API.
Index ¶
Constants ¶
const ( PKI = "pki" SPIFFE = "spiffe" )
Profile names an mTLS profile.
Variables ¶
var ALPN = []string{"h2", "http/1.1"}
ALPN is what both ends offer. Set explicitly rather than left to crypto/tls so the examples negotiate HTTP/2, which is what a service-to-service caller wants and what client.Transport exists to preserve.
Functions ¶
This section is empty.
Types ¶
type Closer ¶
type Closer func() error
Closer releases whatever the config holds open — a reloading credential source, in the SPIFFE case. Never nil.
type Flags ¶
type Flags struct {
// Profile selects the mTLS profile: PKI or SPIFFE.
Profile string
// PKI profile.
PKICert string
PKIKey string
PKIPeerCA string
PKISubject string
PKIAdmitOU string
PKIReload time.Duration
// SPIFFE profile.
SPIFFEDir string
SPIFFETrustDomain string
SPIFFEReload time.Duration
SPIFFEIDs stringList
SPIFFEGKE stringList
// contains filtered or unexported fields
}
Flags is the credential configuration shared by the example server and client.
func (*Flags) Client ¶
Client builds the dialling config.
There is no authenticator half here: a client verifies the server during the handshake and has no inbound request to name.
func (*Flags) Server ¶
Server builds the listener config and the authenticator that reads callers off the connections it admits.
The two are returned together because purser returns them together: the profiles verify with opposite crypto/tls idioms, and an authenticator paired with the wrong listener reads the wrong field.
type Role ¶
type Role int
Role is which end of the connection the flags are being registered for. The two ends take different flags — a server has an identity source to read callers from, a client has a server to authorize — and registering only what applies keeps a flag that silently does nothing off the help text.