Documentation
¶
Overview ¶
Package nodewire supplies private, boot-bound mTLS primitives. It starts no services.
Index ¶
- Constants
- Variables
- func Issue(caDER []byte, caKey ed25519.PrivateKey, csrDER []byte, id Identity, ...) ([]byte, error)
- func NewBoot() (string, error)
- type Guard
- func (g *Guard) BindServer(expected Identity, hostname string) func(tls.ConnectionState) error
- func (g *Guard) ClientTLS(expected Identity, hostname string) (*tls.Config, error)
- func (g *Guard) RecheckServer(ctx context.Context, cs tls.ConnectionState, expected Identity, ...) error
- func (g *Guard) RemoteAuthenticate(r *http.Request) (string, error)
- func (g *Guard) Replace(s *Snapshot) error
- func (g *Guard) Request(r *http.Request) (Identity, error)
- func (g *Guard) ServerTLS() *tls.Config
- func (g *Guard) SourcePeer(c *x509.Certificate) (nodesource.Peer, error)
- type Identity
- type Policy
- type Snapshot
Constants ¶
const MaxLifetime = 24 * time.Hour
Variables ¶
var ErrDenied = errors.New("nodewire: peer denied")
var ErrInvalid = errors.New("nodewire: invalid identity or credentials")
Functions ¶
func Issue ¶
func Issue(caDER []byte, caKey ed25519.PrivateKey, csrDER []byte, id Identity, hosts []string, now time.Time, lifetime, clockSkew time.Duration) ([]byte, error)
Issue signs only a checked Ed25519 CSR with an explicitly supplied Ed25519 CA. CSR extensions/names are never copied; enrollment must authorize id and hosts independently before calling Issue. Returns leaf DER, never a CA private key. Backdating covers clock corrections without relaxing verification. The useful lifetime is capped so the entire encoded validity span stays within MaxLifetime.
Types ¶
type Guard ¶
type Guard struct {
// contains filtered or unexported fields
}
Guard atomically replaces immutable credentials/trust. Policy is mandatory and called outside locks on each check, including operations on reused connections.
func (*Guard) BindServer ¶
BindServer is also usable as nodesource.ClientOptions.BindServer. That hook alone runs at handshake: use RecheckServer on every subsequent operation.
func (*Guard) ClientTLS ¶
ClientTLS returns a fresh independent config for an explicit hostname AND expected identity. Rebuild the transport after root/client credential rotation.
func (*Guard) RecheckServer ¶
func (*Guard) RemoteAuthenticate ¶
RemoteAuthenticate maps the existing remotetranscode boot-only Controller DTO. Its separate Security.Authorize callback remains mandatory.
func (*Guard) Request ¶
Request rechecks current trust, expiry and live membership for every request.
func (*Guard) ServerTLS ¶
ServerTLS selects current credentials/trust per new handshake. Request remains required: neither handshake policy nor TLS session state is current authority.
func (*Guard) SourcePeer ¶
func (g *Guard) SourcePeer(c *x509.Certificate) (nodesource.Peer, error)
SourcePeer fits nodesource.Options.Peer and rechecks current direct-CA trust, validity and live policy on each invocation. That API supplies only a leaf, so intermediate-CA chains must instead use Request at a private HTTP wrapper and an explicitly composed peer mapper. Authority.Verify remains mandatory, including membership/revocation checks during long byte copies.
type Identity ¶
type Identity struct{ Cluster, NodeID, Boot string }
Identity binds the shared cluster, persistent node ID and unique process boot. Boot must be the membership incarnation, never a separately generated TLS boot.
func CertificateIdentity ¶
func CertificateIdentity(c *x509.Certificate) (Identity, error)
CertificateIdentity rejects all extra URI identities and noncanonical aliases.
type Policy ¶
Policy must consult current membership/incarnation and revocation (including serial deny lists if used). Unavailable authority MUST return an error. It grants no placement/source rights; consumers still authorize each operation.