Documentation
¶
Index ¶
- Constants
- func CSRMac(macKey, csrDER []byte) []byte
- func CertPool(caPEM []byte) (*x509.CertPool, []*x509.Certificate, error)
- func GenerateCA(now time.Time, ttl time.Duration) (certPEM, keyPEM []byte, cert *x509.Certificate, err error)
- func NewCAGeneration(generation int, kek []byte, now time.Time, ttl time.Duration) (*models.InternalCAGeneration, *x509.Certificate, error)
- func OpenCAKey(kek, ciphertext, nonce []byte) ([]byte, error)
- func ParseCSRPEM(data []byte) (*x509.CertificateRequest, error)
- func ParseCertificatesPEM(data []byte) ([]*x509.Certificate, error)
- func ParsePrivateKeyPEM(data []byte) (crypto.Signer, error)
- func SealCAKey(kek, plaintext []byte) (ciphertext, nonce []byte, err error)
- func ShouldRenewLeaf(cert *x509.Certificate, now time.Time, renewBefore time.Duration) bool
- func ShouldRollCA(gen *models.InternalCAGeneration, now time.Time, renewBefore time.Duration) bool
- func SignCSR(csrPEM []byte, nodeID string, caCert *x509.Certificate, caKey crypto.Signer, ...) ([]byte, *x509.Certificate, error)
- func TLSCertificate(certPEM, keyPEM []byte) (tls.Certificate, error)
- func TrustPoolFromGenerations(gens []models.InternalCAGeneration, now time.Time) (*x509.CertPool, []*x509.Certificate, error)
- func VerifyCSRMac(macKey, csrDER, got []byte) bool
- type Clock
- type Config
- type DerivedKeys
- type LeaderCheckFunc
- type LeafRequest
- type Material
- type MaterialHolder
- func (h *MaterialHolder) CertPool() (*x509.CertPool, error)
- func (h *MaterialHolder) Certificate() (*tls.Certificate, error)
- func (h *MaterialHolder) Material() (*Material, bool)
- func (h *MaterialHolder) Set(cert tls.Certificate, pool *x509.CertPool, caCerts []*x509.Certificate)
- func (h *MaterialHolder) UpdateTrust(pool *x509.CertPool, caCerts []*x509.Certificate) error
- type Provisioner
- func (p *Provisioner) Bootstrap(ctx context.Context) error
- func (p *Provisioner) Enroll(ctx context.Context) error
- func (p *Provisioner) Holder() *MaterialHolder
- func (p *Provisioner) LeafRenewalDue() bool
- func (p *Provisioner) PruneExpiredCAs(ctx context.Context) (int64, error)
- func (p *Provisioner) RefreshTrust(ctx context.Context) error
- func (p *Provisioner) RollCAIfNeeded(ctx context.Context) error
- func (p *Provisioner) Run(ctx context.Context) error
- func (p *Provisioner) SignPending(ctx context.Context, limit int) (int, error)
- type Store
- func (s *Store) ActiveCAGenerations(ctx context.Context, now time.Time) ([]models.InternalCAGeneration, error)
- func (s *Store) CountCAGenerations(ctx context.Context) (int64, error)
- func (s *Store) CreateCAGenerationIfAbsent(ctx context.Context, gen *models.InternalCAGeneration) (bool, error)
- func (s *Store) CreateEnrollment(ctx context.Context, enrollment *models.InternalNodeEnrollment) error
- func (s *Store) DeleteEnrollment(ctx context.Context, id string) error
- func (s *Store) Enrollment(ctx context.Context, id string) (*models.InternalNodeEnrollment, error)
- func (s *Store) MarkEnrollmentRejected(ctx context.Context, id string, signedAt time.Time) (bool, error)
- func (s *Store) MarkEnrollmentSigned(ctx context.Context, id string, caGeneration int, certPEM string, ...) (bool, error)
- func (s *Store) MaxCAGeneration(ctx context.Context) (int, error)
- func (s *Store) NewestActiveCAGeneration(ctx context.Context, now time.Time) (*models.InternalCAGeneration, error)
- func (s *Store) PendingEnrollments(ctx context.Context, limit int) ([]models.InternalNodeEnrollment, error)
- func (s *Store) PruneExpiredCAGenerations(ctx context.Context, cutoff time.Time) (int64, error)
Constants ¶
const ( EnrollmentStatusPending = "pending" EnrollmentStatusSigned = "signed" EnrollmentStatusRejected = "rejected" )
Variables ¶
This section is empty.
Functions ¶
func GenerateCA ¶
func GenerateCA(now time.Time, ttl time.Duration) (certPEM, keyPEM []byte, cert *x509.Certificate, err error)
GenerateCA creates a self-signed Caesium internal CA certificate and key.
func NewCAGeneration ¶
func NewCAGeneration(generation int, kek []byte, now time.Time, ttl time.Duration) (*models.InternalCAGeneration, *x509.Certificate, error)
NewCAGeneration creates a sealed catalog CA generation row.
func ParseCSRPEM ¶
func ParseCSRPEM(data []byte) (*x509.CertificateRequest, error)
ParseCSRPEM parses a single PEM-encoded certificate request.
func ParseCertificatesPEM ¶
func ParseCertificatesPEM(data []byte) ([]*x509.Certificate, error)
ParseCertificatesPEM parses one or more PEM certificates.
func ParsePrivateKeyPEM ¶
ParsePrivateKeyPEM parses an ECDSA or PKCS#8 private key PEM.
func ShouldRenewLeaf ¶
func ShouldRollCA ¶
func SignCSR ¶
func SignCSR(csrPEM []byte, nodeID string, caCert *x509.Certificate, caKey crypto.Signer, now time.Time, ttl time.Duration) ([]byte, *x509.Certificate, error)
SignCSR verifies csrPEM and signs a constrained non-CA leaf for nodeID. The resulting certificate uses only the CSR public key and the validated node identity; CSR-requested extensions are intentionally ignored.
func TLSCertificate ¶
func TLSCertificate(certPEM, keyPEM []byte) (tls.Certificate, error)
func TrustPoolFromGenerations ¶
func TrustPoolFromGenerations(gens []models.InternalCAGeneration, now time.Time) (*x509.CertPool, []*x509.Certificate, error)
TrustPoolFromGenerations builds the union trust pool from every non-expired CA generation.
func VerifyCSRMac ¶
VerifyCSRMac checks a CSR HMAC using hmac.Equal.
Types ¶
type Config ¶
type Config struct {
Store *Store
NodeID string
Token string
CATTL time.Duration
LeafTTL time.Duration
LeafRenewBefore time.Duration
CARenewBefore time.Duration
EnrollmentTimeout time.Duration
PollInterval time.Duration
RotationInterval time.Duration
TrustRefreshInterval time.Duration
SignBatchSize int
LeaderCheck LeaderCheckFunc
Clock Clock
}
Config controls internal mTLS auto-provisioning.
type DerivedKeys ¶
DerivedKeys are independent HKDF-SHA256 outputs derived from the operator's shared internal token. The raw token is never used for CA encryption or CSR authentication.
func DeriveKeys ¶
func DeriveKeys(token string) (DerivedKeys, error)
DeriveKeys expands token into the CA-key encryption key and CSR MAC key.
type LeafRequest ¶
LeafRequest holds a locally generated private key and CSR. KeyPEM must never be written to the catalog.
func GenerateLeafRequest ¶
func GenerateLeafRequest(nodeID string) (LeafRequest, error)
GenerateLeafRequest creates a node-local leaf keypair and CSR.
type Material ¶
type Material struct {
Certificate tls.Certificate
Leaf *x509.Certificate
Pool *x509.CertPool
CACerts []*x509.Certificate
}
Material is the currently usable node certificate and trust bundle.
type MaterialHolder ¶
type MaterialHolder struct {
// contains filtered or unexported fields
}
MaterialHolder atomically publishes TLS material to server/client callbacks.
func NewMaterialHolder ¶
func NewMaterialHolder() *MaterialHolder
func NewStaticMaterialHolder ¶
func NewStaticMaterialHolder(caFile, certFile, keyFile string) (*MaterialHolder, error)
func (*MaterialHolder) Certificate ¶
func (h *MaterialHolder) Certificate() (*tls.Certificate, error)
func (*MaterialHolder) Material ¶
func (h *MaterialHolder) Material() (*Material, bool)
func (*MaterialHolder) Set ¶
func (h *MaterialHolder) Set(cert tls.Certificate, pool *x509.CertPool, caCerts []*x509.Certificate)
func (*MaterialHolder) UpdateTrust ¶
func (h *MaterialHolder) UpdateTrust(pool *x509.CertPool, caCerts []*x509.Certificate) error
type Provisioner ¶
type Provisioner struct {
// contains filtered or unexported fields
}
func NewProvisioner ¶
func NewProvisioner(cfg Config) (*Provisioner, error)
func (*Provisioner) Bootstrap ¶
func (p *Provisioner) Bootstrap(ctx context.Context) error
Bootstrap blocks until this node has a signed leaf and a non-empty trust pool. The caller should complete this before starting the internal mTLS listener or dispatch loop.
func (*Provisioner) Holder ¶
func (p *Provisioner) Holder() *MaterialHolder
func (*Provisioner) LeafRenewalDue ¶
func (p *Provisioner) LeafRenewalDue() bool
func (*Provisioner) PruneExpiredCAs ¶
func (p *Provisioner) PruneExpiredCAs(ctx context.Context) (int64, error)
func (*Provisioner) RefreshTrust ¶
func (p *Provisioner) RefreshTrust(ctx context.Context) error
func (*Provisioner) RollCAIfNeeded ¶
func (p *Provisioner) RollCAIfNeeded(ctx context.Context) error
func (*Provisioner) Run ¶
func (p *Provisioner) Run(ctx context.Context) error
Run starts the signer/rotation loop. It returns when ctx is cancelled or a non-recoverable PKI operation fails.
func (*Provisioner) SignPending ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store wraps catalog access for internal mTLS CA generations and enrollment rows.