WIP: Add local certificate authority infrastructure #85

Draft
rulkens wants to merge 1 commit from feature/local-ca-infrastructure into main
Member

Summary

  • Move CA setup from inline one-liners to dedicated scripts (fyt-ca-init, fyt-ca-run, fyt-ca-trust, fyt-ca-health) with proper error handling and auto-initialization
  • Store CA config in .step/ within the project folder (via STEPPATH env var) instead of ~/.step
  • Auto-generate CA password and store it securely alongside the CA config
  • fyt-ca-run now auto-initializes and trusts the CA if not yet done
  • fyt-ca-health checks CA reachability from both host and VM
  • VM startup (fyt-vm-run) verifies CA health before proceeding
  • Extract common logging helpers (fyt_info, fyt_warn, fyt_error, fyt_header) into common.sh
  • Move set -euo pipefail from common.sh into create-fyt-command.nix wrapper
  • Add default deployment argument (testing) to VM commands

Test plan

  • Run fyt-ca-init — should create CA in .step/ with auto-generated password
  • Run fyt-ca-run — should start CA on :8443 (auto-init + trust if needed)
  • Run fyt-ca-health — should report healthy when CA is running
  • Run fyt-ca-health without CA running — should show helpful error
  • Run fyt-vm-run — should check CA health before starting VM
  • Verify .step/ is in .gitignore
**Summary** - Move CA setup from inline one-liners to dedicated scripts (`fyt-ca-init, fyt-ca-run, fyt-ca-trust, fyt-ca-health`) with proper error handling and auto-initialization - Store CA config in `.step/` within the project folder (via `STEPPATH` env var) instead of `~/.step` - Auto-generate CA password and store it securely alongside the CA config - `fyt-ca-run` now auto-initializes and trusts the CA if not yet done - `fyt-ca-health` checks CA reachability from both host and VM - VM startup (`fyt-vm-run`) verifies CA health before proceeding - Extract common logging helpers (`fyt_info, fyt_warn, fyt_error, fyt_header`) into `common.sh` - Move `set -euo pipefail` from `common.sh` into `create-fyt-command.nix` wrapper - Add default deployment argument (`testing`) to VM commands **Test plan** - Run `fyt-ca-init` — should create CA in .step/ with auto-generated password - Run `fyt-ca-run` — should start CA on :8443 (auto-init + trust if needed) - Run `fyt-ca-health` — should report healthy when CA is running - Run `fyt-ca-health` without CA running — should show helpful error - Run `fyt-vm-run` — should check CA health before starting VM - Verify `.step/` is in `.gitignore`
rulkens force-pushed feature/local-ca-infrastructure from 51b6e62aa2 to d7a343987c 2026-03-01 23:00:56 +01:00 Compare
rulkens force-pushed feature/local-ca-infrastructure from d7a343987c to 3c0e92fc12 2026-03-01 23:08:43 +01:00 Compare
balint left a comment

I would suggest to submit a PR with one specific feature. It will be harder to get through everything in this PR in one go. I think it will be easier to talk through and agree on one specific change, and then follow those agreements for the ones that come after.

I would suggest to submit a PR with one specific feature. It will be harder to get through everything in this PR in one go. I think it will be easier to talk through and agree on one specific change, and then follow those agreements for the ones that come after.
@ -1,9 +1,16 @@
# Better error handling
Owner

why remove this part?

why remove this part?
@ -7,0 +5,4 @@
fyt_warn() { echo -e "${_FYT_PREFIX} \033[1;33m$*\033[0m" >&2; }
fyt_error() { echo -e "${_FYT_PREFIX} \033[1;31m$*\033[0m" >&2; }
fyt_header() {
echo ""
Owner

could we use multiline strings to reduce the noise from repeating echo -e "..." every line?

could we use multiline strings to reduce the noise from repeating echo -e "..." every line?
@ -25,6 +25,7 @@ let
);
in
(pkgs.writeShellScriptBin name ''
set -euo pipefail
Owner

why put it here instead of the commonsh?

why put it here instead of the commonsh?
@ -58,3 +63,1 @@
fyt-ca-init.exec = "step ca init --name \"Free Your Tech\" --dns \"localhost,10.0.2.2\" --address \":8443\" --provisioner \"admin\" --acme";
fyt-ca-trust.exec = "step certificate install ~/.step/certs/root_ca.crt";
fyt-ca-run.exec = "step-ca ~/.step/config/ca.json";
fyt-ca-init.exec = "bash ${./scripts/fyt-ca-init.sh}";
Owner
  1. I'm fairly sure you don't need to do exec = "bash ${name}";, you can just do exec = name;
  2. I would prefer to use this area just for one-liners, and use the list above to add the more complex functions, unless there's a reason to have these here specifically?
1. I'm fairly sure you don't need to do `exec = "bash ${name}";`, you can just do `exec = name;` 2. I would prefer to use this area just for one-liners, and use the list above to add the more complex functions, unless there's a reason to have these here specifically?
@ -0,0 +1,16 @@
#!/usr/bin/env bash
Owner

why include the sheband when it's never used? adds noise.

why include the sheband when it's never used? adds noise.
@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -euo pipefail
Owner

why was this removed from common and then put into every script individually, when it also sources common?

why was this removed from common and then put into every script individually, when it also sources common?
@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
Owner

again, why?

again, why?
@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -euo pipefail
source "$FYT_COMMON"
Owner

and this too, it's already sourced, no?

and this too, it's already sourced, no?
@ -1,22 +0,0 @@
require_commands cat chmod mktemp
Owner

why rename this file, and also all the other files with having fyt- in the filename, what value does it add in exchange for adding noise to the filenames?

why rename this file, and also all the other files with having fyt- in the filename, what value does it add in exchange for adding noise to the filenames?
balint changed title from Add local certificate authority infrastructure to WIP: Add local certificate authority infrastructure 2026-03-28 15:37:17 +01:00
This pull request has changes conflicting with the target branch.
  • modules/shell/common.sh
  • modules/shell/create-fyt-command.nix
  • modules/shell/default.nix
  • modules/shell/help.sh
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'feature/local-ca-infrastructure:feature/local-ca-infrastructure'
git switch 'feature/local-ca-infrastructure'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
freeyourtech/stack!85
No description provided.