pki

package
v0.1.17 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package pki provides certificate authority and certificate management utilities for the simplified Ploy server/node mTLS architecture.

Index

Constants

View Source
const (
	// CAValidity is the default validity period for the CA certificate.
	CAValidity = 10 * 365 * 24 * time.Hour // 10 years

	// NodeCertValidity is the default validity period for node certificates.
	NodeCertValidity = 365 * 24 * time.Hour // 1 year

	// ServerCertValidity is the default validity period for server certificates.
	ServerCertValidity = 365 * 24 * time.Hour // 1 year

)

Variables

This section is empty.

Functions

This section is empty.

Types

type CABundle

type CABundle struct {
	CertPEM string
	KeyPEM  string
	Cert    *x509.Certificate
	Key     *ecdsa.PrivateKey
}

CABundle represents a certificate authority bundle with both certificate and private key.

func GenerateCA

func GenerateCA(now time.Time) (*CABundle, error)

GenerateCA creates a new certificate authority.

func LoadCA

func LoadCA(certPEM, keyPEM string) (*CABundle, error)

LoadCA loads a CA bundle from PEM-encoded certificate and private key.

type IssuedCert

type IssuedCert struct {
	CertPEM     string
	KeyPEM      string
	Serial      string
	Fingerprint string
	NotBefore   time.Time
	NotAfter    time.Time
	Cert        *x509.Certificate
	Key         *ecdsa.PrivateKey
}

IssuedCert represents an issued certificate with metadata.

func GenerateNodeCSR

func GenerateNodeCSR(nodeID, nodeIP string) (*IssuedCert, []byte, error)

GenerateNodeCSR generates a private key and CSR for a node. The nodeID is used in the certificate CN as "node:<nodeID>". The nodeIP is included in SANs along with the DNS name.

func IssueServerCert

func IssueServerCert(ca *CABundle, serverIP string, now time.Time) (*IssuedCert, error)

IssueServerCert issues a server certificate signed by the CA. It sets the subject CN to "ployd" and includes a "ployd.ploy" DNS SAN. The provided serverIP is also added to IP SANs for direct addressing.

func SignNodeCSR

func SignNodeCSR(ca *CABundle, csrPEM []byte, now time.Time) (*IssuedCert, error)

SignNodeCSR signs a node certificate signing request using the cluster CA. Returns the signed certificate with metadata for persistence.

Jump to

Keyboard shortcuts

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