Skip to content

Sign node and agent certificates without writing a serial file - #2101

Merged
fog-workflows[bot] merged 1 commit into
dev-branchfrom
fix/node-cert-random-serial
Nov 17, 2026
Merged

fog-workflows[bot] merged 1 commit into
dev-branchfrom
fix/node-cert-random-serial

Conversation

@mastacontrola

Copy link
Copy Markdown
Member

Problem

Forum topic 18318 (Debian 12, 1.6.0.158): approving a fog-agent fails. With #2099 the error reads:

signing failed: ...BIO_new_file:Read-only file system ... calling fopen(/etc/fog/pki/agent/ca/.fogAgentCA.srl, w)

The web server's systemd service makes /etc read-only. sudo runs fog-sign-node-cert inside that same sandbox. The helper used -CAcreateserial, which writes a .srl counter beside the CA on every issue. The same signing step run by hand as root succeeds.

Change

  • packages/pki/fog-sign-node-cert: random_serial() gives each certificate a random 128-bit serial (openssl rand -hex 16, validated). -set_serial replaces -CAcreateserial on the agent path and the web/signing path. The helper writes nothing beside the CA. Nothing reads the .srl files.
  • The temporary extension file stays in /tmp. Moving it into the staging directory was considered and rejected: the web user owns that directory and could replace the file before openssl reads it.

Verified

  • In debian:12 (OpenSSL 3.0) with the CA directory mounted read-only, the old helper fails with the reporter's exact error. The new helper issues both types, with a different serial each time.
  • tests/node-cert-external-ca.test.sh case G: a CA directory that the user cannot write. 22 pass on the fix; on the old helper, 3 G checks fail. G is skipped as root, where the chmod cannot bind.
  • agent-ca-follows-root, trust-anchor and node-cert-external-ca tests pass.
  • Reviewed by spec-reviewer and standards-reviewer (both opus), two rounds: both CLEAN.

🤖 Generated with Claude Code

fog-sign-node-cert used `openssl x509 -CAcreateserial`, which writes a
.srl counter beside the CA on every issue. A web server whose systemd
service makes /etc read-only runs the helper inside that sandbox,
because sudo does not leave it. Every agent approval then failed with
"Read-only file system" on /etc/fog/pki/agent/ca/.fogAgentCA.srl
(forum topic 18318, Debian 12).

Each certificate now gets a random 128-bit serial (-set_serial), as a
CA normally assigns them. Nothing reads the .srl counter. The helper
now writes nothing beside the CA.

tests/node-cert-external-ca.test.sh case G issues a web and an agent
certificate with the CA directory read-only. It fails on the old helper.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fog-workflows
fog-workflows Bot enabled auto-merge November 17, 2026 13:55
@fog-workflows
fog-workflows Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into dev-branch with commit e12e01f Nov 17, 2026
12 checks passed
@fog-workflows
fog-workflows Bot deleted the fix/node-cert-random-serial branch November 17, 2026 14:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant