102.8. step-ca-0.30.2
Private certificate authority with ACME
| Version | 0.30.2, release 1 |
| Shelf | security — Security applications: GnuPG and front-ends, password and secret managers, certificates, scanners, forensics and audit |
| Phase | 41_system (System), 932 of 1047 in build order |
| Licence | Apache-2.0 |
| Homepage | https://smallstep.com/docs/step-ca/ |
| Build time | 0.8 SBU |
| Installed size | 48.0 MiB in 3 files |
| Recipe | ports/core/security/step-ca/kpkgbuild |
About
step-ca is Smallstep’s private certificate authority: an online CA that issues X.509 and SSH certificates over its own API and over ACME, so that any ACME client, caddy among them, can obtain and renew certificates from it on a network with no route to a public CA. It is set up and driven with the step-cli command, and the package adds a service script, 89_step-ca, that runs it as root from /etc/step-ca; the Services table says how to set it up.
Why it is in KDOS
The comment above step-cli and step-ca in script/phases/41_system/packages.d/security.txt:
Let's Encrypt needs the internet and a self-signed cert per host means a warning per host that people learn to click through. One root, trusted once, speaking ACME so caddy renews against it with its public config.
step-clicreates that CA (step-cli ca init) and is its client.
Sources
step-ca-0.30.2.tar.gz(878.7 KiB)
sha256327391f301b79818f2418302516b4f6b41bdf08e38edc9011cc7f1b351e19452
upstream: https://github.com/smallstep/certificates/archive/refs/tags/v0.30.2.tar.gz
archive copy: sources-4/security--step-ca-0.30.2.tar.gzstep-ca-vendor-0.30.2.tar.xz(5.6 MiB)
sha256c1049df49ee6ec3bd9c8c060b49c5a470451a845caf2eda9ba9bd516737d4747
a vendor bundle: the dependencies upstream’s own tool would download, packed once
archive copy: sources-4/security--step-ca-vendor-0.30.2.tar.xz
Dependencies
Depends on: go, pkgconf, pcsc-lite, step-cli.
Required by: no port names it.
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install step-ca'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/security/step-ca.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/security/step-ca
echo '327391f301b79818f2418302516b4f6b41bdf08e38edc9011cc7f1b351e19452 step-ca-0.30.2.tar.gz' | sha256sum -c -
echo 'c1049df49ee6ec3bd9c8c060b49c5a470451a845caf2eda9ba9bd516737d4747 step-ca-vendor-0.30.2.tar.xz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/step-ca
SRC=$SRC_ROOT/step-ca-0.30.2
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf step-ca-0.30.2.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
tar xf $PORT_SRC/${name}-vendor-${version}.tar.xz
export CGO_ENABLED=1
go build -mod=vendor -ldflags "-s -w -X main.Version=$version" -o step-ca ./cmd/step-ca
install -Dm755 step-ca $PKG/usr/bin/step-ca
install -d "$PKG/etc/init.d"
cat > "$PKG/etc/init.d/89_step-ca.sh" <<'KDOS_SH'
#!/bin/bash
. /etc/init.d/service_helper
NAME="step-ca"
DAEMON="/usr/bin/step-ca"
export STEPPATH="/etc/step-ca"
case "$1" in
start)
[ ! -x "$DAEMON" ] && { echo "[SKIP] $NAME: $DAEMON not found"; exit 0; }
if [ ! -s "$STEPPATH/config/ca.json" ]; then
echo "[SKIP] $NAME: no $STEPPATH/config/ca.json (STEPPATH=$STEPPATH step-cli ca init makes it)"
exit 0
fi
if [ ! -s "$STEPPATH/password.txt" ]; then
echo "[SKIP] $NAME: no $STEPPATH/password.txt"
exit 0
fi
echo "[KDOS] Starting $NAME..."
supervise "$NAME" "$DAEMON" "$STEPPATH/config/ca.json" \
--password-file "$STEPPATH/password.txt"
;;
stop) stop_service "$NAME" ;;
status) check_status "$NAME" ;;
*) echo "Usage: $0 {start|stop|status}"; exit 1 ;;
esac
KDOS_SH
chmod 755 "$PKG/etc/init.d/89_step-ca.sh"
The switches, and why each is set:
export CGO_ENABLED=1— Build with cgo. step-ca’s PKCS#11 and YubiKey PIV key stores are compiled only with cgo (their files carry//go:build cgo); without it they compile out silently, and akmsblock inca.jsonnaming either fails only when the CA starts. The YubiKey store talks to the key through pcsc-lite, which is independs.-X main.Version=$version— Stamp the release intostep-ca version. Upstream’sMakefilealso stampsmain.BuildTime; the recipe leaves it unset, so two builds of one release are the same binary.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/step-ca, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf step-ca-0.30.2-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/step-ca, and runs the triggers its paths call for.
Contents
Installed programs: step-ca.
Installed directories: /usr/share/licenses/step-ca.
Notes
The Go modules come from the vendor bundle, step-ca-vendor-<version>.tar.xz, which ports/fetch makes with go mod vendor because the recipe says vendoring = go; build.sh unpacks it and builds with -mod=vendor, offline. See Vendoring.
build.sh writes /etc/init.d/89_step-ca.sh. It sets STEPPATH=/etc/step-ca and skips itself, with a [SKIP] line, until both config/ca.json and password.txt exist there: the first is what sudo STEPPATH=/etc/step-ca step-cli ca init writes, and the second holds the CA key’s password, which step-ca reads with --password-file instead of asking for it at a console. Once both exist it starts the CA under the service supervisor, so a crashed CA is restarted. Other machines reach it only after the firewall’s https name is opened, when the CA listens on 443 (see Opening a service).