How SPORK CA Works

SPORK is a Certificate Authority built entirely in Rust. It handles the full certificate lifecycle: key generation, certificate issuance, revocation, and distribution. This page explains its architecture, protocols, and security model.

Architecture Overview

SPORK uses a 3-tier PKI hierarchy: Root CA, Policy CAs, and Issuing CAs. This separation allows the Root CA key to remain offline while Issuing CAs handle day-to-day certificate operations.

Root CA (offline, P-384, 25-year validity)
  |
  +-- Policy CA (per-domain, P-384, 10-year)
        |
        +-- Issuing CA (operational, P-256, 5-year)
              |
              +-- End-entity certificates (TLS, code signing, etc.)

Declarative Hierarchy Builder

CA hierarchies are defined in TOML configuration files and built with spork pki:

# hierarchy.toml
[root]
common_name = "SPORK Root CA"
algorithm = "ecdsa-p384"
validity_years = 25

[[policy_cas]]
common_name = "SPORK TLS Policy CA"
algorithm = "ecdsa-p384"
validity_years = 10

  [[policy_cas.issuing_cas]]
  common_name = "SPORK TLS Web Server Issuing CA"
  algorithm = "ecdsa-p256"
  validity_years = 5
# Validate, preview, and build
spork pki validate hierarchy.toml
spork pki preview hierarchy.toml
spork pki build hierarchy.toml --output /opt/spork/pki

Storage

All CA state is stored in PostgreSQL: certificates, keys (encrypted), revocation lists, ACME accounts/orders, audit logs. The installer bundles PostgreSQL and configures it automatically.

Certificate Lifecycle

StageWhat HappensComponent
1. CA InitializationRoot/Policy/Issuing CA keys generated, self-signed or cross-signed certificates createdspork pki build
2. Key GenerationCryptographic key pair created (ECDSA, RSA, ML-DSA, SLH-DSA, or hybrid)spork-core
3. Certificate RequestCSR received via ACME, EST, SCEP, CMP, or CLIProtocol servers
4. Policy CheckRequest validated against CA policy (allowed names, key types, extensions)spork-core
5. SigningIssuing CA signs the certificate with its private keyspork-core
6. IssuanceCertificate stored in database, returned to requestorspork-db
7. RevocationCertificate marked revoked with reason code (RFC 5280)spork revoke
8. CRL/OCSPRevocation status published via CRL distribution points and OCSP responderspork-crl, spork-ocsp

Enrollment Protocols

SPORK supports four certificate enrollment protocols. Choose based on your use case:

ProtocolRFCBest ForHow It Works
ACME RFC 8555 Web servers, automated TLS Client proves domain control via HTTP-01, DNS-01, or TLS-ALPN-01 challenge. Server issues certificate automatically. Compatible with certbot, win-acme, acme.sh.
EST RFC 7030/8295 Enterprise devices, IoT HTTPS-based enrollment with mutual TLS authentication. Supports simple enroll, re-enroll, and CA certificate distribution. Lightweight and firewall-friendly.
SCEP RFC 8894 MDM, legacy devices HTTP-based enrollment using PKCS#7 envelopes. Widely supported by MDM platforms (Jamf, Intune, SOTI). Challenge-password based authentication.
CMP RFC 9810 Full lifecycle management Most feature-rich protocol. Supports initialization, certification, key update, revocation, and cross-certification requests. Message-level protection.

Post-Quantum Cryptography

SPORK supports NIST's post-quantum standards alongside classical algorithms. Enable with --features pqc at build time.

Migration Strategy

Rather than an abrupt switchover, SPORK supports hybrid certificates that combine a classical signature with a post-quantum signature. This provides backwards compatibility: classical clients verify the ECDSA signature, PQC-aware clients verify both.

AlgorithmStandardSignature SizeUse Case
ML-DSA-44FIPS 2042,420 bytesGeneral purpose (smallest PQC signature)
ML-DSA-65FIPS 2043,309 bytesRecommended default PQC
ML-DSA-87FIPS 2044,627 bytesHighest security level
SLH-DSA-SHA2-128sFIPS 2057,856 bytesHash-based (conservative, stateless)
ML-DSA-65 + ECDSA P-256Composite~3,400 bytesHybrid: backwards compatible + PQC
# Issue a hybrid certificate
spork cert issue --ca "TLS Issuing CA" \
  --cn "server.example.com" \
  --algorithm ml-dsa-65-p256 \
  --type tls-server

Security Model

Admin Certificate Hierarchy

All administrative operations require mutual TLS authentication. Four privilege levels control access:

LevelOIDPermissions
SuperAdmin1.3.6.1.4.1.56266.1.20.4Full access: CA management, key operations, admin cert issuance
Admin1.3.6.1.4.1.56266.1.20.3Certificate issuance, revocation, CRL generation
Operator1.3.6.1.4.1.56266.1.20.2Certificate issuance, read-only revocation view
Viewer1.3.6.1.4.1.56266.1.20.1Read-only: view certificates, CRLs, audit logs

Key Protection

FIPS 140-3 Mode

FIPS 140-3 is enabled by default using aws-lc-rs (NIST Certificate #4816) as the cryptographic backend. Non-FIPS pure Rust mode is available via runtime toggle.

Installer System

SPORK packages are distributed as self-extracting ELF binaries. Each installer is a single file that contains all binaries, configuration templates, systemd units, and the PostgreSQL database engine.

# Download and run
curl -sSLO https://example.com/spork-ca-0.3.0-beta.7-linux-x86_64-installer
chmod +x spork-ca-0.3.0-beta.7-linux-x86_64-installer

# Verify integrity before installing
./spork-ca-0.3.0-beta.7-linux-x86_64-installer --verify

# Install (runs setup wizard)
sudo ./spork-ca-0.3.0-beta.7-linux-x86_64-installer

The spork-setup wizard runs after extraction and handles:

ACME Server

The ACME server implements RFC 8555 and is compatible with standard ACME clients:

ClientPlatformTested
certbotLinuxYes
win-acmeWindowsYes
acme.shLinux/macOSYes
spork acme (built-in)Linux/WindowsYes

Challenge Types

ChallengeHow It WorksRequirements
HTTP-01ACME server verifies a token at http://domain/.well-known/acme-challenge/Port 80 accessible
DNS-01Client creates a _acme-challenge TXT recordDNS API access
TLS-ALPN-01Client presents a self-signed cert with the acmeIdentifier extension on port 443Port 443 accessible

Windows IIS Integration

The built-in ACME client can deploy certificates directly to Windows IIS:

spork acme issue \
  --server https://acme.example.com/directory \
  --domain www.example.com \
  --deploy iis \
  --iis-site "Default Web Site"

This handles the full pipeline: ACME challenge, certificate issuance, PFX conversion, IIS binding update, and HTTPS verification.

Code Signing

The spork-sign package provides CMS/PKCS#7 code signing and Authenticode signature capabilities:

# Sign a binary
spork sign code --key signing-key.pem --cert signing-cert.pem --input app.exe --output app-signed.exe

# Timestamp a signature
spork sign tsa --url http://tsa.example.com/tsa --input signature.p7s

WebUI

SPORK includes a web-based admin dashboard built with Axum and server-rendered HTML. It provides:

Access is controlled via mTLS (admin certificate required) or session-based login. Destructive operations always require mTLS.

Ceremony System

For high-assurance CA operations, SPORK includes a formal ceremony framework modeled after enterprise CAs like Entrust and DigiCert. Key ceremonies ensure that critical operations (root key generation, CA signing) happen under multi-party control.

15 Ceremony Action Types

#ActionDescription
1GenerateRootKeyGenerate the root CA key pair
2GenerateIntermediateKeyGenerate an intermediate CA key pair
3SelfSignRootRoot CA signs its own certificate
4SignIntermediateParent CA signs child CA certificate
5CrossCertifyCross-certify between independent CAs
6GenerateCrlGenerate a CRL signed by the CA
7RevokeCARevoke a CA certificate
8BackupKeyCreate encrypted backup of key material
9CreateKeySharesSplit key into N-of-M Shamir secret shares
10RecoverFromSharesReconstruct key from M shares
11VerifyChainValidate the full certificate chain
12ExportPublicExport public certificates for distribution
13ImportTrustAnchorImport external trust anchors
14AuditLogRecord audit entry with witness signatures
15CustomActionOrganization-specific ceremony steps

N-of-M Key Sharing (Shamir Secret Sharing)

Root CA keys can be split into M shares where any N shares are sufficient to reconstruct the key. For example, a 3-of-5 scheme means 5 key custodians each hold a share, and any 3 must be present to use the root key.

# In a ceremony plan:
[[actions]]
type = "CreateKeyShares"
key_id = "root-ca"
threshold = 3    # N shares needed
total_shares = 5 # M total shares

Each ceremony produces an encrypted ceremony file with a complete audit trail: who participated, what actions were taken, timestamps, and verification hashes. The ceremony verifier can independently validate the entire ceremony log.

Note: The ceremony library is complete. CLI integration is planned for a future release. Currently, CA setup uses spork pki for declarative hierarchy building.