Repository navigation
Sign node and agent certificates without writing a serial file - #2101
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
/etcread-only.sudorunsfog-sign-node-certinside that same sandbox. The helper used-CAcreateserial, which writes a.srlcounter 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_serialreplaces-CAcreateserialon the agent path and the web/signing path. The helper writes nothing beside the CA. Nothing reads the.srlfiles./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
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.shcase 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-anchorandnode-cert-external-catests pass.🤖 Generated with Claude Code