pki

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2026 License: GPL-3.0 Imports: 13 Imported by: ? 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

Index

Constants

View Source
const (
	DefaultCACommonName   = "DVFS Offline Root CA"
	DefaultCAOrganization = "DVFS Project"
	DefaultCAOU           = "Security"
	DefaultCACountry      = "IN"
	DefaultCAProvince     = "Gujarat"
	DefaultCALocality     = "Gandhinagar"
	DefaultCAValidityDays = 3652 // 10 years + 2 leap days
	DefaultCAKeyBits      = 4096
)

DefaultRootCAConfig defines standard parameters for the DVFS Root CA.

View Source
const (
	DefaultNodeValidityDays = 730 // 2 years
	DefaultNodeKeyBits      = 4096
)

Variables

This section is empty.

Functions

func LoadCACert

func LoadCACert(certPath string) (*x509.Certificate, []byte, error)

LoadCACert reads and parses only the public CA certificate without requiring the private key.

func SyncClientCA

func SyncClientCA(certPEM []byte) error

SyncClientCA finds the repository root and automatically updates internal/client/ca.go with the provided certPEM.

Types

type NodeCertOptions

type NodeCertOptions struct {
	NodeName     string
	Organization string
	ValidityDays int
	KeyBits      int
	ExtraDNS     []string
	ExtraIPs     []net.IP
}

NodeCertOptions configures the generation of a node certificate.

func DefaultNodeCertOptions

func DefaultNodeCertOptions(nodeName string) NodeCertOptions

DefaultNodeCertOptions returns production options with standard SANs for a cluster node.

type NodeCertificate

type NodeCertificate struct {
	NodeName    string
	Certificate *x509.Certificate
	PrivateKey  *rsa.PrivateKey
	CertPEM     []byte
	KeyPEM      []byte
}

NodeCertificate holds in-memory artifacts for a signed node certificate.

func GenerateNodeCert

func GenerateNodeCert(ca *RootCA, opts NodeCertOptions) (*NodeCertificate, error)

GenerateNodeCert generates an RSA private key and a leaf certificate signed by the Root CA.

func (*NodeCertificate) Save

func (nc *NodeCertificate) Save(nodeDir string) error

Save writes server.crt and server.key into the specified directory. server.key is written with 0600 permissions.

type RootCA

type RootCA struct {
	Certificate *x509.Certificate
	PrivateKey  *rsa.PrivateKey
	CertPEM     []byte
	KeyPEM      []byte
}

RootCA holds the generated in-memory certificate, private key, and PEM encodings.

func GenerateRootCA

func GenerateRootCA(opts RootCAOptions) (*RootCA, error)

GenerateRootCA creates a new self-signed Root CA with a 10+ year validity period. The private key must be kept offline and never copied to server or client devices.

func LoadCA

func LoadCA(certPath, keyPath string) (*RootCA, error)

LoadCA loads an existing Root CA certificate and private key from disk.

func (*RootCA) Save

func (ca *RootCA) Save(outDir string) error

Save writes ca.crt and ca.key to the target directory. ca.key is set to restrictive permissions (0400).

type RootCAOptions

type RootCAOptions struct {
	CommonName   string
	Organization string
	OU           string
	Country      string
	Province     string
	Locality     string
	ValidityDays int
	KeyBits      int
}

RootCAOptions configures generation of the Root CA.

func DefaultRootCAOptions

func DefaultRootCAOptions() RootCAOptions

DefaultRootCAOptions returns standard production-grade options for the Root CA.

Jump to

Keyboard shortcuts

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