!MthpOIxqJhTgrMNxDS:nixos.org

NixOS ACME / LetsEncrypt

103 Members
Another day, another cert renewal42 Servers

Load older messages


SenderMessageTime
27 Dec 2021
@m1cr0man:m1cr0man.comm1cr0manhaha so many emails from the 8 closed tickets16:59:24
29 Dec 2021
@winterqt:nixos.devWinter (she/her) In https://github.com/NixOS/nixpkgs/blob/ac169ec6371f0d835542db654a65e0f2feb07838/nixos/modules/security/acme.nix#L417, it says that this makes it readable to the group specified by the cert service, but the perms for /var/lib/acme are 0750. Wouldn't the cert be inaccessible even by the group specified by the cert service, then? 03:03:55
@winterqt:nixos.devWinter (she/her)ah, I see https://github.com/NixOS/nixpkgs/blob/ac169ec6371f0d835542db654a65e0f2feb07838/nixos/modules/security/acme.nix#L294 now03:07:40
@winterqt:nixos.devWinter (she/her) So because of the fix permission service having its working directory set to /var/lib/acme, I guess acme:acme would be the owner of /var/lib/acme. 03:09:35
@winterqt:nixos.devWinter (she/her) But then wouldn't the permissions of 0750 would still disallow access to the cert specified groups? 03:10:19
@winterqt:nixos.devWinter (she/her) * But then wouldn't the permissions of 0750 still disallow access to the cert specified groups? 03:10:27
@winterqt:nixos.devWinter (she/her)
      # These StateDirectory entries negate the need for tmpfiles
      StateDirectory = [ "acme" "acme/.lego" "acme/.lego/accounts" ];
      StateDirectoryMode = 755;
      WorkingDirectory = "/var/lib/acme";

...ah.

03:16:37
@m1cr0man:m1cr0man.comm1cr0man yeah, we really went all-in on statedirectory/systemd activation logic for the folder creation. It ended up solving all previous permissions issues we were encountering, whilst also providing systemctl clean --what=state acme-mydomain.service for easy full renewals 13:22:39
@m1cr0man:m1cr0man.comm1cr0manThere's a bunch of really difficult to figure out logic wrt when directories need to be created, recreated or permissions changed which all depend on systemd service activation. Hence, it was best to leave it to systemd where possible13:30:20
30 Dec 2021
@winterqt:nixos.devWinter (she/her)Redacted or Malformed Event04:44:03
@winterqt:nixos.devWinter (she/her) Also: the useACMEHost option in Nginx vhosts doesn't set the group for the certificate, so it (unexpectedly) fails to start. I can't find any documentation that requires anything other than setting useACMEHost, though, so I don't think I'm doing anything wrong. 04:54:21
@m1cr0man:m1cr0man.comm1cr0man You do need to set the group explicitly when using useACMEHost. We can't assume that the cert is being used for other purposes in that scenario, thus it would be unsafe to set the group automatically 15:01:20
@m1cr0man:m1cr0man.comm1cr0man * You do need to set the group explicitly when using useACMEHost. We can't assume that the cert is being used for only ngnix/apache in that scenario, thus it would be unsafe to set the group automatically 15:01:37
@winterqt:nixos.devWinter (she/her)

Got it. I feel like that can definitely be documented better, I’ll PR if I can think of adequate wording.

Question: why can’t we assume, though? In what scenario would someone be using one certificate across multiple HTTP servers? idk, just seems unlikely, it’s definitely best not to assume but i can’t think of an actual practical use case unless I’m just missing something obvious…

20:05:16
@winterqt:nixos.devWinter (she/her)maybe something something different ports something something?20:07:50
@m1cr0man:m1cr0man.comm1cr0manone wildcard for mail and web is a use case I used to maintain for a deployment21:14:33
@m1cr0man:m1cr0man.comm1cr0manI added nginx + dovecot + postfix users to acme group21:14:56
@winterqt:nixos.devWinter (she/her)Redacted or Malformed Event23:18:59
31 Dec 2021
@m1cr0man:m1cr0man.comm1cr0manwoohoo finally nixos-unstable is updated :)13:28:55
@winterqt:nixos.devWinter (she/her) changed their display name from Winter to Winter (she/her).22:07:41
2 Jan 2022
@m1cr0man:m1cr0man.comm1cr0manhttps://nixos.org/manual/nixos/unstable/index.html#module-security-acme-config-dns lol XD18:50:16
@m1cr0man:m1cr0man.comm1cr0manso uh18:50:19
@m1cr0man:m1cr0man.comm1cr0man

This is in the example on how to auto generate TSIG keys with a systemd service. https://nixos.org/manual/nixos/unstable/index.html#module-security-acme-config-dns
Spot the issue? :P
I'll do a PR at some point.. maybe tomorrow

    cat > /var/lib/secrets/certs.secret << EOF
    RFC2136_NAMESERVER='127.0.0.1:53'
    RFC2136_TSIG_ALGORITHM='hmac-sha256.'
    RFC2136_TSIG_KEY='rfc2136key.example.com'
    RFC2136_TSIG_SECRET='your secret key'
    EOF
18:51:11
@m1cr0man:m1cr0man.comm1cr0manWinter I was thinking that it might be possible to add an assertion in nginx/httpd/caddy to check acme cert access too, which would at least cover your concern about it unexpectedly failing. It would be complex though, idk if nix does anything in the config tree to merge users.users.<name>.extraGroups and users.groups.<name>.extraUsers that I could reference18:52:32
@winterqt:nixos.devWinter (she/her)
In reply to @m1cr0man:m1cr0man.com
Winter I was thinking that it might be possible to add an assertion in nginx/httpd/caddy to check acme cert access too, which would at least cover your concern about it unexpectedly failing. It would be complex though, idk if nix does anything in the config tree to merge users.users. .extraGroups and users.groups. .extraUsers that I could reference
Do you mean users.groups..members?
21:14:59
@m1cr0man:m1cr0man.comm1cr0manyeah sorry, trying to remember it off the top of my head21:15:28
@winterqt:nixos.devWinter (she/her) m1cr0man: You’ll be pleased to know that it does do merging of them, users.groups.<name>.members is the source of truth. (https://github.com/NixOS/nixpkgs/blob/59bfda72480496f32787cec8c557182738b1bd3f/nixos/modules/config/users-groups.nix#L362) 23:03:14
@winterqt:nixos.devWinter (she/her)I’d be happy to take a stab at adding the assertions to the modules, if you’d be okay with that.23:03:36
@m1cr0man:m1cr0man.comm1cr0manAwesome find! :D Yeah absolutely, I'll review it as soon as I can (but I'll be going offline soon for tonight)23:08:49
@winterqt:nixos.devWinter (she/her)I’ll do it sometime tomorrow most likely, so that’s perfectly fine.23:16:11

Show newer messages


Back to Room ListRoom Version: 6