Commit Graph

15 Commits

Author SHA1 Message Date
Christian Theune
2d0a489125 nixos/acme: improve scalability - reduce superfluous unit activations
The previous setup caused all renewal units to be triggered upon
ever so slight changes in config. In larger setups (100+ certificates)
adding a new certificate caused high system load and/or large memory
consumption issues. The memory issues are already a alleviated with
the locking mechanism. However, this then causes long delays upwards
of multiple minutes depending on individual runs and also caused
superfluous activations.

In this change we streamline the overall setup of units:

1. The unit that other services can depend upon is 'acme-{cert}.service'.
We call this the 'base unit'. As this one as `RemainAfterExit` set
the `acme-finished-{cert}` targets are not required any longer.

2. We now always generate initial self-signed certificates to simplify
the dependency structure. This deprecates the `preliminarySelfsigned`
option.

3. The `acme-order-renew-{cert}` service gets activated after the base
unit and services using certificates have started and performs all acme
interactions. When it finishes others services (like web servers) will
be notified through the `reloadServices` option or they can use
`wantedBy` and `after` dependencies if they implement their own reload
units.

The renewal timer also triggers this unit.

4. The timer unit is explicitly blocked from being started by s-t-c.

5. Permission management has been cleaned up a bit: there was an
   inconsistency between having the .lego files set to 600 vs 640
   on the exposed side. This is unified to 640 now.

6. Exempt the account target from being restarted by s-t-c. This will
   happen automatically if something relevant to the account changes.
2025-08-08 16:28:42 +02:00
โทสฺตัล
093d5cfaea nixos/step-ca: add H2O test 2025-02-24 15:06:34 +07:00
โทสฺตัล
9555f3e8be nixos/step-ca: fixup Caddy comment typos 2025-02-24 15:06:34 +07:00
โทสฺตัล
2281c12585 nixos/step-ca: nixfmt + add Python syntax hint
Helps when writing & using a editor with tree-sitter support
2025-02-24 15:06:34 +07:00
Jeremy Fleischman
afee631853 nixos/step-ca: use pathWith for intermediatePasswordFile
This lets us remove an assertion, because `pathWith` can require that a
file not be in the store.

Note that the old assertion didn't quite do what we wanted: it prevented
you from using top level store paths (such as
`/nix/store/gg8578vvbcf1wpqvk85bigi5s4pvylkk-test-certificates`), but was
ok with sub-files (such as
`/nix/store/gg8578vvbcf1wpqvk85bigi5s4pvylkk-test-certificates/intermediate-password-file`).

Now that we're stricter, we need some way to populate
`intermediatePasswordFile` in our test without making the type unhappy.
I opted to solve that by creating a file in `/etc`.
2025-02-21 20:39:20 -08:00
Jeremy Fleischman
7f9ea915ff nixosTests.step-ca: wait for caddy to finish ACME dance
On my machine, I see that this `curl` command often fails. This is
because the caddy server hasn't finished the ACME dance with the step-ca
server yet.

This seems like the simplest fix. Alternatives I considered (and would
be happy to implement if folks prefer):

- Use `wait_for_file` to wait for the certificate to appear
- Increase caddy's log level and scrape its logs for the "certificate obtained"
  message.
2025-02-15 10:06:12 +07:00
Frédéric Christ
c6f6c28218 nixos/testing: Add ipv6 configuration
This contribution enables a working IPv6 setup by default. This works
analog to the current automatic IPv4 setup.
2024-07-18 10:22:32 +02:00
Moraxyc
212d236936 nixosTests.step-ca: fix journal error 2024-05-21 20:21:26 +08:00
Aleksana
f1f4eb1e36 Merge pull request #312626 from jpds/step-ldflags-version
step-ca: Set version in ldflags so this is correctly displayed in startup
2024-05-19 22:12:11 +08:00
Jonathan Davies
52743c88f5 nixos/step-ca: Added test case for finding package version in journald logs 2024-05-18 22:24:04 +01:00
Jonathan Davies
d01d430342 nixos/step-ca: Added Caddy example to integration tests. 2024-05-18 10:43:23 +01:00
K900
2d3cf010fe Revert "treewide: use nativeBuildInputs with runCommand instead of inlining" 2022-12-26 21:05:35 +03:00
Sandro Jäckel
26f704b545 treewide: use nativeBuildInputs with runCommand instead of inlining 2022-12-18 23:36:40 +01:00
Jonathan Ringer
6af7f6eb78 tests/step-ca: give name, fix acme usage 2022-03-14 22:45:02 -07:00
Moritz Hedtke
9d01ce82ac nixos/tests: add step-ca test 2021-11-13 12:40:47 +01:00