diff --git a/CHANGELOG.md b/CHANGELOG.md index b2f2311..c5b3aec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,12 @@ Kryptkeeper adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html ## [Unreleased] +### Fixed + +- Building the images from source on an x86_64 host produced an ARM binary that would not start (`exec format error`). The Dockerfiles no longer default `TARGETARCH`; a build without it targets the builder's own architecture. Released images were not affected. +- `docs/guides/getting-started.md` matches the current Compose setup (`.env`, TLS by default) and API, and every step was run on a fresh VM. +- `scripts/day-one-estate.sh` uses a valid scan type, waits for the scan and its certificates before reporting, takes `CACERT` for a TLS hub, and no longer fails on long reports. The day-one run is recorded in [docs/release/DAY_ONE_RUN_v1.1.md](docs/release/DAY_ONE_RUN_v1.1.md). + ## [1.1.1] - 2026-10-27 Release notes: [docs/release/RELEASE_NOTES_v1.1.1.md](docs/release/RELEASE_NOTES_v1.1.1.md). diff --git a/Dockerfile b/Dockerfile index f492274..ae1b98e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,7 +21,9 @@ FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder ARG TARGETOS=linux -ARG TARGETARCH=arm64 +# Empty unless BuildKit or --build-arg sets it; the build then targets the +# builder's own architecture (a hard-coded default built arm64 binaries on x86_64). +ARG TARGETARCH ARG BUILD_MODE=real ARG APP_BUILD_PATH=./cmd/kryptkeeper ARG HEALTHCHECK_URL=http://127.0.0.1:8080/healthz @@ -59,17 +61,17 @@ if [ "${BUILD_MODE}" = "real" ]; then # tested package (HEALTHCHECK_CA_FILE support, needed once the hub's # default listener serves a self-issued TLS certificate) instead of an # inline plain-HTTP-only probe. - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags='-s -w' -o /out/healthcheck ./cmd/healthcheck - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \ -o /out/kryptkeeper "${APP_BUILD_PATH}" # G-29: always ship the MCP server binary too, independent of # APP_BUILD_PATH -- this is a fixed source path, not the configurable # primary-binary one above. - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags='-s -w' -o /out/kryptkeeper-mcp ./cmd/kryptkeeper-mcp elif [ "${BUILD_MODE}" = "placeholder" ]; then # Placeholder mode has no module tree beyond this single file, so it gets @@ -106,7 +108,7 @@ func main() { } EOGO - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags='-s -w' -o /out/healthcheck /tmp/generated/healthcheck.go # Placeholder path for release safety before app sources are wired. @@ -137,7 +139,7 @@ func main() { } EOGO - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags='-s -w' -o /out/kryptkeeper /tmp/generated/placeholder.go # No real app sources are available in this mode (that is the whole diff --git a/Dockerfile.agent b/Dockerfile.agent index 8571fcd..472828f 100644 --- a/Dockerfile.agent +++ b/Dockerfile.agent @@ -16,7 +16,9 @@ FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder ARG TARGETOS=linux -ARG TARGETARCH=amd64 +# Empty unless BuildKit or --build-arg sets it; the build then targets the +# builder's own architecture (a hard-coded default built arm64 binaries on x86_64). +ARG TARGETARCH # W20-02: stamps this binary's version/commit/date vars. ARG VERSION=dev ARG COMMIT=unknown @@ -26,7 +28,7 @@ WORKDIR /src COPY . /src RUN --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \ -o /out/kryptkeeper-agent ./cmd/kryptkeeper-agent diff --git a/Dockerfile.certmanager b/Dockerfile.certmanager index 1accd5a..9302d79 100644 --- a/Dockerfile.certmanager +++ b/Dockerfile.certmanager @@ -13,7 +13,9 @@ FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder ARG TARGETOS=linux -ARG TARGETARCH=amd64 +# Empty unless BuildKit or --build-arg sets it; the build then targets the +# builder's own architecture (a hard-coded default built arm64 binaries on x86_64). +ARG TARGETARCH # W20-02: stamps this binary's version/commit/date vars. ARG VERSION=dev ARG COMMIT=unknown @@ -23,7 +25,7 @@ WORKDIR /src COPY . /src RUN --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \ -o /out/kryptkeeper-certmanager ./cmd/kryptkeeper-certmanager diff --git a/Dockerfile.fips b/Dockerfile.fips index 739f402..ac14812 100644 --- a/Dockerfile.fips +++ b/Dockerfile.fips @@ -17,7 +17,9 @@ FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder ARG TARGETOS=linux -ARG TARGETARCH=arm64 +# Empty unless BuildKit or --build-arg sets it; the build then targets the +# builder's own architecture (a hard-coded default built arm64 binaries on x86_64). +ARG TARGETARCH ARG GOFIPS140=v1.0.0 ARG APP_BUILD_PATH=./cmd/kryptkeeper ARG HEALTHCHECK_URL=http://127.0.0.1:8080/healthz @@ -43,14 +45,14 @@ if [ ! -e "/src/${APP_BUILD_PATH#./}" ]; then exit 1 fi -GOFIPS140="${GOFIPS140}" CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ +GOFIPS140="${GOFIPS140}" CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags='-s -w' -o /out/healthcheck ./cmd/healthcheck -GOFIPS140="${GOFIPS140}" CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ +GOFIPS140="${GOFIPS140}" CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \ -o /out/kryptkeeper "${APP_BUILD_PATH}" -GOFIPS140="${GOFIPS140}" CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ +GOFIPS140="${GOFIPS140}" CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags='-s -w' -o /out/kryptkeeper-mcp ./cmd/kryptkeeper-mcp EOF diff --git a/Dockerfile.mcp b/Dockerfile.mcp index 1142fa1..fd44367 100644 --- a/Dockerfile.mcp +++ b/Dockerfile.mcp @@ -13,7 +13,9 @@ FROM --platform=$BUILDPLATFORM golang:1.27-alpine AS builder ARG TARGETOS=linux -ARG TARGETARCH=amd64 +# Empty unless BuildKit or --build-arg sets it; the build then targets the +# builder's own architecture (a hard-coded default built arm64 binaries on x86_64). +ARG TARGETARCH # W20-02: stamps this binary's version/commit/date vars. ARG VERSION=dev ARG COMMIT=unknown @@ -23,7 +25,7 @@ WORKDIR /src COPY . /src RUN --mount=type=cache,target=/root/.cache/go-build \ - CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH}" \ + CGO_ENABLED=0 GOOS="${TARGETOS}" GOARCH="${TARGETARCH:-$(go env GOARCH)}" \ go build -trimpath -ldflags="-s -w -X main.version=${VERSION} -X main.commit=${COMMIT} -X main.date=${DATE}" \ -o /out/kryptkeeper-mcp ./cmd/kryptkeeper-mcp diff --git a/README.md b/README.md index 3009eb2..dc1ab9b 100644 --- a/README.md +++ b/README.md @@ -6,21 +6,25 @@ [![Go Report Card](https://goreportcard.com/badge/github.com/bpmforge/kryptkeeper)](https://goreportcard.com/report/github.com/bpmforge/kryptkeeper) [![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](LICENSE) -Kryptkeeper is a self-hosted certificate authority. Use it to replace Active Directory Certificate Services (AD CS) or to run beside it. It speaks ACME, EST, SCEP, CMP and Windows autoenrollment. It is one Go binary and works offline. Apache 2.0. +Kryptkeeper is a self-hosted certificate authority and certificate lifecycle manager. It can replace Active Directory Certificate Services (AD CS) or run beside it. It also manages certificates that other CAs issued: it finds them, assigns owners, renews them through their own CA or yours, and installs them on the servers that use them, with verify and rollback. It is one Go binary and works offline. Apache 2.0. -**What you get:** -- A certificate authority (root and issuing CAs, templates, revocation) with OCSP and CRL responders +**As a CA:** +- Root and issuing CAs, templates, revocation, and OCSP and CRL responders - Enrollment over ACME, EST, SCEP, CMP and MS-XCEP/MS-WSTEP (Windows autoenrollment), plus Intune SCEP - An AD CS importer and a cutover path, so you can run beside AD CS first and move over later -- Inventory from network scans, CT log monitoring, agentless WinRM and agentless SSH discovery -- Expiry alerts to email, webhooks, Slack, PagerDuty and more -- The option to issue through the CA you already run (see [Use your existing CA](#use-your-existing-ca)) -It also has a PQC migration copilot, an MCP server, SPIFFE support and flag-gated multi-tenancy. They are described lower down. +**As a lifecycle manager, for certificates from any CA:** +- Inventory from network scans, CT log monitoring, agentless WinRM and SSH discovery, an AD CS sync, cloud certificate services and bulk import +- Each certificate marked managed, externally managed or unmanaged, with an owner and a risk score +- Renewal through the issuing CA (any ACME CA, SCEP, EST, Vault PKI, EJBCA and the commercial-CA connectors) or through a Kryptkeeper CA (see [Use your existing CA](#use-your-existing-ca)) +- Install, verify and rollback on IIS, nginx, Apache, HAProxy, Tomcat and Kubernetes Secrets, with approvals and an append-only audit log +- Expiry alerts to email, webhooks, Slack, PagerDuty and more + +It also has a PQC migration copilot, an SSH certificate authority, an MCP server, SPIFFE support and flag-gated multi-tenancy. They are described lower down. ## Project status -I am the only maintainer (@bpmforge). I build Kryptkeeper with heavy use of Claude Code. I design the features, run every lab test listed in this repository and review what ships. +I am the only maintainer (@bpmforge). I have worked on PKI, key management and security architecture for more than 13 years: at a security vendor, an IT services firm and a cloud provider. I build Kryptkeeper with heavy use of Claude Code. I design the features, run every lab test listed in this repository and review what ships. There has been no external penetration test yet. The OpenSSF Scorecard score is 4.6 out of 10 as of October 2026. @@ -36,6 +40,10 @@ Every line below points at a dated record in [`docs/release/`](docs/release/). I - **Protocols and CA:** ACME, EST, SCEP, CMP, OCSP and CRL ran against real clients in the 1.0.0 lab pass ([`LIVE_RESULTS_v1.0.0.md`](docs/release/LIVE_RESULTS_v1.0.0.md)). SCEP from F5 and Palo Alto appliances has not been run. - **Windows:** GPO autoenrollment, WSTEP renewal and IIS push passed on Windows 11 25H2 and Server 2022 ([`LIVE_RESULTS_v1.0.0.md`](docs/release/LIVE_RESULTS_v1.0.0.md), [`LIVE_RESULTS_v1_WINDOWS.md`](docs/release/LIVE_RESULTS_v1_WINDOWS.md)). A new Server 2025 member enrolled the same way, and all three accepted the 1.1 key-usage profile with chains validating ([`LIVE_RESULTS_WINDOWS_KU_WS2025_v1.1.md`](docs/release/LIVE_RESULTS_WINDOWS_KU_WS2025_v1.1.md)). Windows 10 and Server 2019 were not tested. +- **AD CS cutover:** a rehearsal against a live AD CS on Windows Server 2025 passed all six steps of the [cutover playbook](docs/guides/replace-adcs.md): live inventory sync, template import, takeover of a domain-joined Windows 11 machine, re-sync and revert ([`ADCS_CUTOVER_REHEARSAL_v0.21.md`](docs/release/ADCS_CUTOVER_REHEARSAL_v0.21.md)). +- **Install, verify and rollback:** agentless SSH installs passed 43 of 43 checks on nginx, Apache, HAProxy and Tomcat ([`LIVE_RESULTS_SSH_INSTALL_v0.15.md`](docs/release/LIVE_RESULTS_SSH_INSTALL_v0.15.md)), and IIS push, verify and rollback passed in the 1.0.0 lab pass ([`LIVE_RESULTS_v1.0.0.md`](docs/release/LIVE_RESULTS_v1.0.0.md)). +- **Renewal at another CA:** SCEP and EST renewal ran against independent CA servers ([`LIVE_RESULTS_UPSTREAM_RENEW_v0.15.md`](docs/release/LIVE_RESULTS_UPSTREAM_RENEW_v0.15.md)); ACME renewal at Let's Encrypt staging with Cloudflare DNS-01, followed by SSH install and verify, passed in the 1.0.0 lab pass and again on 1.1.0 ([`LIVE_RESULTS_v1.0.0.md`](docs/release/LIVE_RESULTS_v1.0.0.md), [`LIVE_RESULTS_v1.1.0_REGRESSION.md`](docs/release/LIVE_RESULTS_v1.1.0_REGRESSION.md)). +- **Day-one estate picture:** on a new Ubuntu VM, a bulk import, a network scan and an AD CS export from a real enterprise CA became one risk-scored estate of 29 certificates, with the estate report, dashboard and seeded counts in agreement. Following the docs as written took 19 minutes and hit five defects in the docs, the Dockerfile and the script; all five are fixed, and a rerun from an empty hub passed with no workarounds ([`DAY_ONE_RUN_v1.1.md`](docs/release/DAY_ONE_RUN_v1.1.md)). - **Discovery:** TLS, protocol and agentless SSH certificate discovery passed on real sshd and seeded endpoints ([`LIVE_RESULTS_v1.0.0.md`](docs/release/LIVE_RESULTS_v1.0.0.md), [`LIVE_INVENTORY_v1.md`](docs/release/LIVE_INVENTORY_v1.md)). - **Single sign-on:** OIDC, SAML and SCIM passed 39 of 39 checks against a real Keycloak 26 container ([`LIVE_RESULTS_KEYCLOAK_v0.21.md`](docs/release/LIVE_RESULTS_KEYCLOAK_v0.21.md)). We have not tested other identity providers. - **Key storage:** PKCS#11 on SoftHSM2, and Vault transit against a Vault dev server, passed ([`LIVE_RESULTS_v1.0.0.md`](docs/release/LIVE_RESULTS_v1.0.0.md)). AWS KMS, Azure Key Vault and GCP Cloud KMS passed against emulators only. No vendor HSM and no real cloud KMS account has been tried. diff --git a/docs/ROADMAP.md b/docs/ROADMAP.md index c482a55..cfaa202 100644 --- a/docs/ROADMAP.md +++ b/docs/ROADMAP.md @@ -51,6 +51,7 @@ Last updated: 2026-10-27. | Merge the IP and hostname views of the same server | A server scanned by IP and by name shows up as two endpoints. | Later | post-0.9.3 planning | | Agent reports unreadable files and listening ports the same way agentless scans do | Today the agent silently skips files it cannot read, so a gap in coverage looks like nothing is there. Includes the live agent test for this report. | 1.1 | W34-09 | | Browser test for a target blocked by a root-owned install path | Proves end to end that the dashboard explains why such a target is blocked and clears once the credential is switched to helper mode. | 1.1 | W33-26 | +| Mark a scan job completed only after its certificates are in the inventory | A job reports `completed` a few seconds before its certificates appear in the estate, so anything that reads the estate right after must wait. | 1.2 | DAY_ONE_RUN_v1.1 | ## Renewal, issuance and CA operations @@ -134,6 +135,7 @@ Last updated: 2026-10-27. | Code and config comments cite docs/design/SECURITY_PRINCIPLES.md | About 25 Go, YAML and shell comments still name the private contributor rules file (`CLAUDE.md`) as the source of a rule; the public docs already point at the security principles page. | 1.2 | public cleanup 2026-10-27 | | Five-minute trial: one command brings up a hub with demo data | Evaluators should reach a working dashboard before they read a guide. | 1.1 | W37 | | Nightly fuzzing on a dedicated runner | The nightly fuzz workflow uses the same `ubuntu-latest` label as PR CI, so it lands on whichever shared Mac runner is free and competes with interactive dev work. It needs its own label and a dedicated (or cloud) runner. | 1.1 | M5 runner 2026-10-27 | +| Stamp the version into images built with Docker Compose | Source builds report version `dev`, so a support question cannot tell which code a hub runs. | 1.2 | DAY_ONE_RUN_v1.1 | ## Website and walkthroughs diff --git a/docs/guides/day-one-estate.md b/docs/guides/day-one-estate.md index abb5edb..2436221 100644 --- a/docs/guides/day-one-estate.md +++ b/docs/guides/day-one-estate.md @@ -5,7 +5,8 @@ before value. This guide gets a fresh Kryptkeeper install to a risk-scored, PQC-split estate report — covering certificates you issued, certificates other CAs issued, and certificates nobody was tracking — in one sitting. The companion script -`scripts/day-one-estate.sh` runs the same path non-interactively. +`scripts/day-one-estate.sh` runs the same path non-interactively. Against a Compose +hub, pass `CACERT=ca.pem` (the hub serves TLS with its own root). ## Stage names and failure codes @@ -57,9 +58,11 @@ spreadsheet's folder, or a CSV) and import it on the On the **Discovery** page start a scan of your server ranges. -- API: `POST /api/v1/discovery/scans` with a CIDR or host:port - target; progress and results on the same page - (`GET /api/v1/discovery/scans`, endpoints list). +- API: `POST /api/v1/discovery/scans` with `scan_type` (`fast`, + `targeted`, `full` or `deep`) and a CIDR or host `target`; follow the job + with `GET /api/v1/discovery/scan-jobs` and the results with + `GET /api/v1/discovery/endpoints`. The script starts a `full` scan and waits + for its job to finish (`SCAN_WAIT_SECONDS`, default 600) before it reports. - Failure modes: unreachable hosts land as per-endpoint errors on the scan result — visible, not fatal to the sweep; a huge CIDR is bounded by the scanner's concurrency and timeout settings. diff --git a/docs/guides/getting-started.md b/docs/guides/getting-started.md index efb9214..5dced68 100644 --- a/docs/guides/getting-started.md +++ b/docs/guides/getting-started.md @@ -1,140 +1,138 @@ # Getting Started with Kryptkeeper -This guide takes you from zero to issuing your first certificate in under 15 minutes -using Docker Compose. +This guide takes you from zero to issuing, verifying and revoking your first +certificate with Docker Compose. On a fresh Ubuntu 24.04 VM with 4 vCPU, the +first `docker compose up` built and started the hub in under 3 minutes +([`DAY_ONE_RUN_v1.1.md`](../release/DAY_ONE_RUN_v1.1.md)). ## Prerequisites -- Docker 24+ and Docker Compose v2 -- `curl` and `openssl` in your shell +- Docker 24+ with Docker Compose v2 and BuildKit (on Ubuntu: + `apt install docker.io docker-compose-v2 docker-buildx`) +- `curl`, `openssl` and `jq` in your shell ## 1. Start the Hub ```bash git clone https://github.com/bpmforge/kryptkeeper.git cd kryptkeeper +cp env.example .env +``` -# Generate a random bootstrap token for first-time setup -export KK_TOKEN=$(openssl rand -hex 20) -echo "Bootstrap token: $KK_TOKEN" +Edit `.env` and set two values. Compose refuses to start without either, and +they must differ: +```bash +APP_BOOTSTRAP_TOKEN= +KRYPTKEEPER_KEYSTORE_PASSPHRASE= +``` + +Then start it: + +```bash docker compose up -d ``` -The Hub starts on port **8080** (HTTP) by default. -Set `KRYPTKEEPER_ADDR=:443` and mount TLS certs for production. +The first start builds the images from source and creates a default root CA +(`KRYPTKEEPER_BOOTSTRAP_CREATE_ROOT=true` in `env.example`). The API listens on +**https://localhost:8080** with a certificate from that root; the dashboard is +on **http://localhost:3000**. ### Verify it's running +Export the hub's CA certificate once and use it with every `curl`: + ```bash -curl -s http://localhost:8080/healthz +docker run --rm -v kryptkeeper_tls-trust:/trust:ro alpine cat /trust/ca.pem > ca.pem +curl --cacert ca.pem https://localhost:8080/healthz # → {"status":"ok"} ``` -## 2. Create a Root CA +Set up your shell for the steps below, using the `APP_BOOTSTRAP_TOKEN` from +`.env` as the bearer token: ```bash -curl -s -X POST http://localhost:8080/api/v1/cas \ - -H "Authorization: Bearer $KK_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "My Root CA", - "common_name": "My Organisation Root CA", - "algorithm": "ECDSA-P384", - "validity_days": 3650 - }' | jq . +export TOKEN= +API=https://localhost:8080/api/v1 +auth=(--cacert ca.pem -H "Authorization: Bearer $TOKEN") ``` -Note the `"id"` field — you will need it in the next step. +## 2. Find (or create) a Root CA ```bash -export CA_ID="" +# The default root CA created on first start +CA_ID=$(curl -s "${auth[@]}" $API/cas | jq -r '.data[0].id') + +# Optional: create another root CA instead (subject_cn is the only required field) +curl -s "${auth[@]}" -X POST $API/cas -H "Content-Type: application/json" \ + -d '{"name": "My Root CA", "type": "root", "subject_cn": "My Root CA", "algorithm": "ECDSA-P256"}' | jq . ``` ## 3. Create a Certificate Template -```bash -curl -s -X POST http://localhost:8080/api/v1/templates \ - -H "Authorization: Bearer $KK_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "tls-server", - "display_name": "TLS Server Certificate", - "validity_period": "P90D", - "key_usage": ["digitalSignature", "keyEncipherment"], - "extended_key_usage": ["serverAuth"], - "allowed_algorithms": ["ECDSA-P256", "ECDSA-P384"], - "auto_enroll": false, - "active": true - }' | jq . +A fresh install has no templates, and issuance requires one. -export TEMPLATE_ID="" +```bash +TEMPLATE_ID=$(curl -s "${auth[@]}" -X POST $API/templates -H "Content-Type: application/json" -d '{ + "name": "tls-server", + "display_name": "TLS Server (90 days)", + "key_usage": ["digitalSignature"], + "extended_key_usage": ["serverAuth"], + "allowed_algorithms": ["ECDSA", "RSA"], + "validity_period": "P90D", + "active": true +}' | jq -r '.data.id') ``` ## 4. Issue a Certificate -Generate a key and CSR: +Issuance is CSR-in: you keep the private key, and Kryptkeeper only sees the CSR. ```bash -openssl ecparam -genkey -name prime256v1 -noout -out server.key -openssl req -new -key server.key \ - -subj "/CN=myapp.example.com" \ - -out server.csr -``` +openssl req -new -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes \ + -keyout server.key -out server.csr -subj "/CN=app.example.com" \ + -addext "subjectAltName=DNS:app.example.com" -Issue the certificate: +FINGERPRINT=$(jq -n --arg ca "$CA_ID" --arg tpl "$TEMPLATE_ID" --rawfile csr server.csr \ + '{ca_id: $ca, template_id: $tpl, csr_pem: $csr}' | + curl -s "${auth[@]}" -X POST $API/certificates -H "Content-Type: application/json" -d @- | + jq -r '.data.fingerprint_sha256') -```bash -curl -s -X POST http://localhost:8080/api/v1/certificates \ - -H "Authorization: Bearer $KK_TOKEN" \ - -H "Content-Type: application/json" \ - -d "{ - \"ca_id\": \"$CA_ID\", - \"template_id\": \"$TEMPLATE_ID\", - \"csr_pem\": \"$(cat server.csr | awk '{printf "%s\\n", $0}')\" - }" | jq -r '.data.certificate_pem' > server.crt - -openssl x509 -in server.crt -noout -subject -dates +curl -s "${auth[@]}" "$API/certificates/$FINGERPRINT/download?format=pem" -o leaf.pem +curl -s "${auth[@]}" "$API/cas/$CA_ID/chain?format=pem" -o root.pem +openssl verify -CAfile root.pem leaf.pem +# → leaf.pem: OK ``` ## 5. Revoke the Certificate ```bash -FINGERPRINT=$(openssl x509 -in server.crt -noout -fingerprint -sha256 \ - | sed 's/.*=//' | tr -d ':' | tr '[:upper:]' '[:lower:]') - -curl -s -X POST http://localhost:8080/api/v1/certificates/$FINGERPRINT/revoke \ - -H "Authorization: Bearer $KK_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{"reason": "superseded"}' +curl -s "${auth[@]}" -X POST "$API/certificates/$FINGERPRINT/revoke" \ + -H "Content-Type: application/json" -d '{"reason": "superseded"}' | jq . ``` ## 6. Issue a Post-Quantum Certificate -Kryptkeeper supports ML-DSA (FIPS 204) out of the box. +Kryptkeeper issues ML-DSA (FIPS 204) certificates. Create a template that +allows it, then follow +[`pqc-certificate.md`](pqc-certificate.md) to issue one and check it with +OpenSSL 3.5. ```bash -# Create a PQC template -curl -s -X POST http://localhost:8080/api/v1/templates \ - -H "Authorization: Bearer $KK_TOKEN" \ - -H "Content-Type: application/json" \ - -d '{ - "name": "pqc-client", - "display_name": "PQC Client Certificate", - "validity_period": "P90D", - "key_usage": ["digitalSignature"], - "extended_key_usage": ["clientAuth"], - "allowed_algorithms": ["ML-DSA-65"] - }' | jq -r '.data.id' - -# Issue via ACME (kryptkeeper-agent handles key gen and enrollment automatically) -KRYPTKEEPER_HUB_URL=http://localhost:8080 \ -KRYPTKEEPER_AGENT_NAME=my-laptop \ - kryptkeeper-agent +curl -s "${auth[@]}" -X POST $API/templates -H "Content-Type: application/json" -d '{ + "name": "pqc-client", + "display_name": "PQC Client Certificate", + "validity_period": "P90D", + "key_usage": ["digitalSignature"], + "extended_key_usage": ["clientAuth"], + "allowed_algorithms": ["ML-DSA-65"] +}' | jq -r '.data.id' ``` ## Next steps +- [Day one: a complete estate picture](day-one-estate.md): import, scan and + sync what you already have, and get a risk-scored report. - [Connect to Microsoft Intune via BYOCA SCEP](intune-byoca.md) - [Deploy with Kubernetes and Helm](../deployment.md#kubernetes--helm-production) - [Use the Terraform provider](../../deploy/terraform/README.md) diff --git a/docs/release/DAY_ONE_RUN_v0.12.md b/docs/release/DAY_ONE_RUN_v0.12.md index 5895d65..e82a887 100644 --- a/docs/release/DAY_ONE_RUN_v0.12.md +++ b/docs/release/DAY_ONE_RUN_v0.12.md @@ -1,5 +1,8 @@ # Day-one estate run — v0.12 +> Superseded: the timed run was done on 2026-10-28 and is recorded in +> [`DAY_ONE_RUN_v1.1.md`](DAY_ONE_RUN_v1.1.md). + Status: **PENDING-RUN**. The timed clean-VM run is a human/ops activity. Every measured field below is the literal `PENDING-RUN` until an operator replaces it. Section 6 was produced locally (no VM, no hub). Nothing here is an invented timing or count. ## 1. Header diff --git a/docs/release/DAY_ONE_RUN_v1.1.md b/docs/release/DAY_ONE_RUN_v1.1.md new file mode 100644 index 0000000..1510ad2 --- /dev/null +++ b/docs/release/DAY_ONE_RUN_v1.1.md @@ -0,0 +1,129 @@ +# Day-one estate run — v1.1 + +The timed run that [`DAY_ONE_RUN_v0.12.md`](DAY_ONE_RUN_v0.12.md) left as +PENDING-RUN: a clean VM to a risk-scored estate report in which the estate +report, the dashboard and the seeded counts agree. + +## Verdict: PASS, after fixing five defects the run found + +On the first run, following the docs as written failed four times before the +estate verified. Each defect is fixed in the same change as this record, and a +second run from an empty hub passed with no workarounds: + +1. `docs/guides/getting-started.md` step 1 exported a token that Compose does + not read, so `docker compose up` stopped on the missing + `KRYPTKEEPER_KEYSTORE_PASSPHRASE`. Its API examples used old field names and + plain HTTP as well. +2. `Dockerfile` and `Dockerfile.fips` set `ARG TARGETARCH=arm64`. A source build + on x86_64 produced an ARM binary, and the hub crash-looped with + `exec /kryptkeeper: exec format error`. That covers the README Quick Start on + any x86_64 Linux host. The agent, cert-manager and MCP Dockerfiles defaulted + to amd64, the same bug for arm64 hosts. Released images were not affected, + because goreleaser passes `TARGETARCH` explicitly. +3. `scripts/day-one-estate.sh` started its scan with `scan_type: network`, + which the API no longer accepts (HTTP 400). +4. The script piped the PQC report into `head -c 400` under `pipefail`. Any + report longer than the preview failed the report stage. +5. The script's verify stage ran as soon as the scan was submitted. A scan + job also reports `completed` a few seconds before its certificates appear + in the estate. The fixed script waits for both (`SCAN_WAIT_SECONDS`). + +The guide also documented `GET /api/v1/discovery/scans`, which returns 405; the +status endpoint is `GET /api/v1/discovery/scan-jobs`. + +## 1. Header + +| Field | Value | +|---|---| +| Date | 2026-10-28 (17:36Z to 18:02Z) | +| Run 1 source | public `main` at 9aad236 (product code identical to v1.1.1; later commits are docs, CI and site tooling), as documented | +| Run 2 source | the same tree plus the fixed `Dockerfile` and `scripts/day-one-estate.sh` from this change | +| Hub version string | `dev` (Compose builds from source and does not stamp a version) | +| Operator | automated agent run (Claude), authorized by the owner on 2026-10-28 | + +## 2. Environment + +| Field | Value | +|---|---| +| VM | new KVM guest from the Ubuntu 24.04.5 LTS cloud image, 4 vCPU, 4 GiB RAM, 30 GB disk, created for this run | +| Container runtime | Ubuntu's `docker.io` 29.1.3 and `docker-compose-v2` 2.40.3, plus `docker-buildx` 0.30.1 | +| Hub install path | Docker Compose, SQLite, TLS on (Compose defaults) | +| Seed: certs in PEM bundle (N) | 12, from three private CAs plus two self-signed (one expired, two RSA-1024, one expiring in 10 days) | +| Seed: endpoints in scan range (M) | 5 nginx TLS endpoints on an isolated Docker network (172.31.250.0/28) on the same VM | +| Seed: AD CS export certs (K) | 11, exported with `certutil -view` from the lab's AD CS enterprise CA on Windows Server 2025 (1 domain controller certificate, 10 user certificates), synced as an `adcs_export` source | +| CT monitoring | SKIPPED: CT results depend on what public logs hold on the day, so the counts could not be seeded. CT is proven separately in [`LIVE_RESULTS_CT_v1.1.md`](LIVE_RESULTS_CT_v1.1.md) | +| EXPECT_TOTAL / MANAGED / EXTERNAL / UNMANAGED | 29 / 1 / 11 / 17 (12 + 5 + 11 seeded, plus the hub's own TLS certificate, which is internal and managed) | + +## 3. Timeline + +### Run 1: the docs as written + +| Stage | Start | End | Duration | Result | +|---|---|---|---|---| +| VM created and booted, cloud-init done | 17:36:09 | 17:38:32 | 2m 23s | PASS | +| Docker prerequisites installed | 17:38:32 | 17:39:08 | 36s | PASS | +| getting-started.md step 1 (`docker compose up`) | 17:39:14 | 17:39:22 | 8s | FAIL: defect 1 | +| README Quick Start (`.env`, `docker compose up`), first build | 17:39:42 | 17:42:04 | 2m 22s | FAIL: hub crash-loops, defect 2 | +| Diagnosis; installing `docker-buildx` and rebuilding did not help | 17:42 | 17:48:43 | about 6m | FAIL: still an ARM binary | +| Build with `--build-arg TARGETARCH=amd64`, start, first login | 17:49:11 | 17:51:30 | 2m 19s | PASS: `/healthz` ok, bootstrap token is `pki-admin`, dashboard 200 | +| Seed data prepared (bundle, endpoints, AD CS export) | 17:51:30 | 17:53:50 | about 2m 20s | PASS | +| Script, attempt 1 | 17:54:00 | 17:54:16 | 16s | FAIL at scan: defect 3 | +| Script, attempt 2 (scan type fixed locally) | 17:54:37 | 17:54:37 | under 1s | FAIL at report: defect 4 | +| Script, attempt 3 (report pipe fixed locally) | 17:55:32 | 17:55:33 | 1s | PASS: counts verified 29 / 1 / 11 / 17 | + +Attempt 3 passed only because attempt 2's scan had finished in the meantime; +run 2 found that race (defect 5). + +### Run 2: the fixed tree, from an empty hub + +Hub volumes and images were deleted first (`docker compose down -v`). + +| Stage | Start | End | Duration | Result | +|---|---|---|---|---| +| Build without a build argument (binary checked: ELF x86-64), start, first login | 17:59:07 | 17:59:40 | 33s (layers cached from run 1) | PASS | +| Script, first try | 17:59:40 | 18:00:01 | 21s | FAIL at verify, 24 of 29: defect 5. The five scanned certificates appeared 11 s later | +| Script wait added; volumes deleted again; build, start, login | 18:01:03 | 18:01:24 | 21s | PASS | +| Script: hub, import, scan (waited for the job and its 5 certificates), sync, report, verify | 18:01:24 | 18:01:49 | 25s | PASS: counts verified | + +## 4. Wall-clock total + +- Run 1, VM creation to verified estate following the docs as written: + 19m 24s (17:36:09 to 17:55:33), about 9 minutes of it spent hitting and + working around the defects above. +- Run 2, empty hub to verified estate with the fixes: 46s (cached build). + A cold first build took 2m 22s in run 1. + +TOTAL < 8h: PASS. + +## 5. Counts (run 2) + +| Field | Seeded | /reports/estate | Dashboard | +|---|---|---|---| +| total | 29 | 29 | 29 | +| managed | 1 | 1 | 1 | +| external | 11 | 11 | 11 | +| unmanaged | 17 | 17 | 17 | + +By origin: internal 1, imported 12, discovered 5, synced 11. +PQC split: 20 vulnerable, 4 migration-ready, 5 not applicable, 0 quantum-safe +(PQC score 13%). Risk: 3 critical, 20 high, 3 medium, 3 low. + +## 6. What this run did not cover + +- The scanned endpoints were containers on the hub VM, not separate servers. + Discovery against real hosts is covered in + [`LIVE_RESULTS_v1.0.0.md`](LIVE_RESULTS_v1.0.0.md). +- The AD CS certificates came in through an export file. The live LDAP + connector against the same CA is covered in + [`ADCS_CUTOVER_REHEARSAL_v0.21.md`](ADCS_CUTOVER_REHEARSAL_v0.21.md). +- The numbers were checked through the API (`/reports/estate` and + `/dashboard/summary`); the dashboard pages were not walked through by hand. +- Day two (taking over an unmanaged certificate) was not part of this run. + +## 7. Artifacts (run 2) + +| File | sha256 | +|---|---| +| kryptkeeper-estate-2026-10-28.json | f21b56d8bcae22b169b2fbd034c6c47b664bacf8d66ecb62698069b27525ade7 | +| kryptkeeper-estate-2026-10-28.pdf | 94c0bfd031842c44f907bacfa53c4fea0aebba2c283a8e0d5579c4271e0fefba | +| kryptkeeper-estate-2026-10-28.csv | 9ebd6d5d72a99af18cc271503260f0bb58f1c1da0ef0435df74194f3a9c0beda | diff --git a/scripts/day-one-estate.sh b/scripts/day-one-estate.sh index 782ab10..7fcd641 100644 --- a/scripts/day-one-estate.sh +++ b/scripts/day-one-estate.sh @@ -8,8 +8,14 @@ # [PEM_BUNDLE=./certs.pem] [SCAN_TARGET=10.0.0.0/24] \ # [ADCS_EXPORT_PATH=/exports/adcs] \ # [EXPECT_TOTAL=n EXPECT_MANAGED=n EXPECT_EXTERNAL=n EXPECT_UNMANAGED=n] \ +# [CACERT=./ca.pem] [SCAN_WAIT_SECONDS=600] \ # bash scripts/day-one-estate.sh # +# CACERT is the hub's TLS CA (Compose serves https with its own root; see +# getting-started.md for exporting ca.pem). The scan stage waits, up to +# SCAN_WAIT_SECONDS, for its scan job to finish and for every certificate it +# mapped to reach the estate, so verify counts what it found. +# # Stages and exit codes: hub=10 import=20 scan=30 sync=40 report=50 verify=60. # Any other failure exits 1 and names CURRENT_STAGE. Set # KK_DAYONE_INJECT_FAIL= to force that stage to fail (tests the @@ -24,6 +30,7 @@ API="$BASE_URL/api/v1" : "${TOKEN:?set TOKEN to an API token with admin rights}" auth=(-H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json") +if [ -n "${CACERT:-}" ]; then auth+=(--cacert "$CACERT"); fi CURRENT_STAGE=init say() { CURRENT_STAGE="$2"; printf '\n== Stage %s — %s: %s\n' "$1" "$2" "$3"; } @@ -71,10 +78,40 @@ fi say 3 scan "network scan (${SCAN_TARGET:-skipped})" maybe_inject scan 30 if [ -n "${SCAN_TARGET:-}" ]; then - curl -fsS "${auth[@]}" -X POST "$API/discovery/scans" \ - -d "{\"scan_type\":\"network\",\"target\":\"$SCAN_TARGET\"}" || fail scan 30 - echo - echo " watch progress on the Discovery page" + job=$(curl -fsS "${auth[@]}" -X POST "$API/discovery/scans" \ + -d "{\"scan_type\":\"full\",\"target\":\"$SCAN_TARGET\"}") || fail scan 30 + job_id=$(printf '%s' "$job" | python3 -c 'import json,sys;print(json.load(sys.stdin)["data"]["scan_job"]["id"])') || fail scan 30 + echo " scan job $job_id started; waiting up to ${SCAN_WAIT_SECONDS:-600}s (progress on the Discovery page)" + deadline=$(( $(date +%s) + ${SCAN_WAIT_SECONDS:-600} )) + while :; do + status=$(curl -fsS "${auth[@]}" "$API/discovery/scan-jobs" | python3 -c ' +import json,sys +jobs=json.load(sys.stdin)["data"]["scan_jobs"] +print(next((j["status"] for j in jobs if j["id"]==sys.argv[1]), "missing"))' "$job_id") || fail scan 30 + case "$status" in + completed) echo " scan completed"; break ;; + queued|running) ;; + *) echo " scan job ended as $status" >&2; fail scan 30 ;; + esac + [ "$(date +%s)" -lt "$deadline" ] || { echo " scan still $status after ${SCAN_WAIT_SECONDS:-600}s" >&2; fail scan 30; } + sleep 5 + done + # A completed job's certificates reach the inventory a few seconds later. + # Wait until every certificate discovery mapped is an estate row, so the + # reports below count them. + # A scan can also map a certificate the estate already holds under another + # origin (the hub's own, say), so a total that holds still for three reads + # also ends the wait. + last=-1; steady=0 + while :; do + mapped=$(curl -fsS "${auth[@]}" "$API/discovery/summary" | python3 -c 'import json,sys;print(json.load(sys.stdin)["data"]["mapped_certificates"])') || fail scan 30 + read -r found total < <(curl -fsS "${auth[@]}" "$API/reports/estate" | python3 -c 'import json,sys;d=json.load(sys.stdin)["data"];print(d["by_origin"]["discovered"], d["total"])') || fail scan 30 + [ "$found" -ge "$mapped" ] && { echo " $found discovered certificates in the estate"; break; } + if [ "$total" = "$last" ]; then steady=$((steady + 1)); else steady=0; last=$total; fi + [ "$steady" -ge 3 ] && { echo " $found of $mapped mapped certificates are discovered rows; estate steady at $total"; break; } + [ "$(date +%s)" -lt "$deadline" ] || { echo " only $found of $mapped discovered certificates reached the estate" >&2; fail scan 30; } + sleep 2 + done else echo " skipped (set SCAN_TARGET to a CIDR or host:port)" fi @@ -93,7 +130,11 @@ fi say 6 report "the payoff" maybe_inject report 50 -curl -fsS "${auth[@]}" "$API/reports/pqc-migration" | head -c 400 || fail report 50 +# Saved first, then shown: piping curl into head would fail under pipefail +# whenever the report is longer than the preview. +pqc="kryptkeeper-pqc-$today.json" +curl -fsS "${auth[@]}" "$API/reports/pqc-migration" -o "$pqc" || fail report 50 +head -c 400 "$pqc" echo csv="kryptkeeper-estate-$today.csv" pdf="kryptkeeper-estate-$today.pdf"