pki

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 17 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 pki is the controller's internal certificate authority (§6.1, §14). It issues the agent gateway's server certificate and signs agents' client certificates from CSRs, so node private keys never leave the node.

Index

Constants

View Source
const (

	// NodeCertValidity bounds how long a stolen node key is useful; agents renew before expiry.
	NodeCertValidity = 90 * 24 * time.Hour
	// GatewayName is in every gateway certificate. Agents that reach the
	// gateway through Traefik send another name (agent.<domain>, for
	// routing) and check the certificate for this one, so the domain can
	// change without new certificates.
	GatewayName = "syncloud-gateway"
)

Variables

This section is empty.

Functions

func MarshalKeyPEM

func MarshalKeyPEM(key *ecdsa.PrivateKey) ([]byte, error)

func NewNodeKey

func NewNodeKey(hostname string) (keyPEM, csrPEM []byte, err error)

NewNodeKey generates a node key pair and a CSR for it (agent side).

func ParseCertPEM

func ParseCertPEM(b []byte) (*x509.Certificate, error)

func PinnedTLS

func PinnedTLS(pin string) *tls.Config

PinnedTLS accepts exactly the server whose leaf public key matches pin (from SPKIPin), whoever signed it: for joining a controller that only has a self-signed certificate.

func SPKIPin

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

SPKIPin is the SHA-256 pin of a PEM certificate's public key, in curl's --pinnedpubkey form: "sha256//<base64>".

Types

type CA

type CA struct {
	Cert    *x509.Certificate
	CertPEM []byte
	// contains filtered or unexported fields
}

func LoadOrCreateCA

func LoadOrCreateCA(dir string) (*CA, error)

LoadOrCreateCA loads <dir>/ca.crt and ca.key, creating them on first start.

func (*CA) Pool

func (ca *CA) Pool() *x509.CertPool

Pool returns a cert pool containing only this CA.

func (*CA) ServerCert

func (ca *CA) ServerCert(hosts []string, validity time.Duration) (tls.Certificate, error)

ServerCert issues a TLS server certificate for the given DNS names and IPs.

func (*CA) SignNodeCSR

func (ca *CA) SignNodeCSR(csrPEM []byte, nodeID string) (certPEM []byte, serial string, err error)

SignNodeCSR issues a client certificate for nodeID from the node's CSR. The subject comes from nodeID, never from the CSR.

Jump to

Keyboard shortcuts

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