about summary refs log tree commit diff
path: root/nixos/modules/security/acme.nix
Commit message (Collapse)AuthorAge
* Merge pull request #86347 from m1cr0man/dnsdocsFlorian Klink2020-05-04
|\ | | | | nixos/acme: update documentation
| * nixos/acme: fix incorrect exampleLucas Savva2020-05-02
| |
| * nixos/acme: update documentationLucas Savva2020-04-29
| |
* | Merge pull request #83121 from emilazy/acme-use-ec256Yegor Timoshenko2020-05-03
|\ \ | | | | | | nixos/acme: change default keyType to ec256
| * | nixos/acme: change default keyType to ec256Emily2020-03-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the NixOS ACME module defaulted to using P-384 for TLS certificates. I believe that this is a mistake, and that we should use P-256 instead, despite it being theoretically cryptographically weaker. The security margin of a 256-bit elliptic curve cipher is substantial; beyond a certain level, more bits in the key serve more to slow things down than add meaningful protection. It's much more likely that ECDSA will be broken entirely, or some fatal flaw will be found in the NIST curves that makes them all insecure, than that the security margin will be reduced enough to put P-256 at risk but not P-384. It's also inconsistent to target a curve with a 192-bit security margin when our recommended nginx TLS configuration allows 128-bit AES. [This Stack Exchange answer][pornin] by cryptographer Thomas Pornin conveys the general attitude among experts: > Use P-256 to minimize trouble. If you feel that your manhood is > threatened by using a 256-bit curve where a 384-bit curve is > available, then use P-384: it will increases your computational and > network costs (a factor of about 3 for CPU, a few extra dozen bytes > on the network) but this is likely to be negligible in practice (in a > SSL-powered Web server, the heavy cost is in "Web", not "SSL"). [pornin]: https://security.stackexchange.com/a/78624 While the NIST curves have many flaws (see [SafeCurves][safecurves]), P-256 and P-384 are no different in this respect; SafeCurves gives them the same rating. The only NIST curve Bernstein [thinks better of, P-521][bernstein] (see "Other standard primes"), isn't usable for Web PKI (it's [not supported by BoringSSL by default][boringssl] and hence [doesn't work in Chromium/Chrome][chromium], and Let's Encrypt [don't support it either][letsencrypt]). [safecurves]: https://safecurves.cr.yp.to/ [bernstein]: https://blog.cr.yp.to/20140323-ecdsa.html [boringssl]: https://boringssl.googlesource.com/boringssl/+/e9fc3e547e557492316932b62881c3386973ceb2 [chromium]: https://bugs.chromium.org/p/chromium/issues/detail?id=478225 [letsencrypt]: https://letsencrypt.org/docs/integration-guide/#supported-key-algorithms So there's no real benefit to using P-384; what's the cost? In the Stack Exchange answer I linked, Pornin estimates a factor of 3× CPU usage, which wouldn't be so bad; unfortunately, this is wildly optimistic in practice, as P-256 is much more common and therefore much better optimized. [This GitHub comment][openssl] measures the performance differential for raw Diffie-Hellman operations with OpenSSL 1.1.1 at a whopping 14× (even P-521 fares better!); [Caddy disables P-384 by default][caddy] due to Go's [lack of accelerated assembly implementations][crypto/elliptic] for it, and the difference there seems even more extreme: [this golang-nuts post][golang-nuts] measures the key generation performance differential at 275×. It's unlikely to be the bottleneck for anyone, but I still feel kind of bad for anyone having lego generate hundreds of certificates and sign challenges with them with performance like that... [openssl]: https://github.com/mozilla/server-side-tls/issues/190#issuecomment-421831599 [caddy]: https://github.com/caddyserver/caddy/blob/2cab475ba516fa725d012f53ca417c3e039607de/modules/caddytls/values.go#L113-L124 [crypto/elliptic]: https://github.com/golang/go/tree/2910c5b4a01a573ebc97744890a07c1a3122c67a/src/crypto/elliptic [golang-nuts]: https://groups.google.com/forum/#!topic/golang-nuts/nlnJkBMMyzk In conclusion, there's no real reason to use P-384 in general: if you don't care about Web PKI compatibility and want to use a nicer curve, then Ed25519 or P-521 are better options; if you're a NIST-fearing paranoiac, you should use good old RSA; but if you're a normal person running a web server, then you're best served by just using P-256. Right now, NixOS makes an arbitrary decision between two equally-mediocre curves that just so happens to slow down ECDH key agreement for every TLS connection by over an order of magnitude; this commit fixes that. Unfortunately, it seems like existing P-384 certificates won't get migrated automatically on renewal without manual intervention, but that's a more general problem with the existing ACME module (see #81634; I know @yegortimoshenko is working on this). To migrate your certificates manually, run: $ sudo find /var/lib/acme/.lego/certificates -type f -delete $ sudo find /var/lib/acme -name '*.pem' -delete $ sudo systemctl restart 'acme-*.service' nginx.service (No warranty. If it breaks, you get to keep both pieces. But it worked for me.)
* | | nixos/acme: set maintainers to acme teamEmily2020-04-20
| |/ |/|
* | Merge pull request #85365 from immae/fix_acme_postrunworldofpeace2020-04-18
|\ \ | | | | | | nixos/acme: Fix postRun in acme certificate being ran at every run
| * | nixos/acme: Fix postRun in acme certificate being ran at every runIsmaël Bouya2020-04-17
| | |
* | | Revert "nixos/acme: Fix allowKeysForGroup not applying immediately"Arian van Putten2020-04-16
|/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit 5532065d0690645f0a813fed6e68163b0f4774d4. As far as I can tell setting RemainAfterExit=true here completely breaks certificate renewal, which is really bad! the sytemd timer will activate the service unit every OnCalendar=, however with RemainAfterExit=true the service is already active! So the timer doesn't rerun the service! The commit also broke the actual tests, (As it broke activation too) but this was fixed later in https://github.com/NixOS/nixpkgs/pull/76052 I wrongly assumed that PR fixed renewal too, which it didn't! testing renewals is hard, as we need to sleep in tests.
* | acme: share accounts between certificatesLucas Savva2020-04-14
| | | | | | | | | | There are strict rate limits on account creation for Let's Encrypt certificates. It is important to reuse credentails when possible.
* | acme: create certificates in subdirectoryJörg Thalheim2020-04-09
| | | | | | | | | | | | | | This allows to have multiple certificates with the same common name. Lego uses in its internal directory the common name to name the certificate. fixes #84409
* | nixos/acme: don't depend on multi-user.target inside a containerMaximilian Bosch2020-03-29
|/ | | | | | | On boot, a container doesn't have an uplink and would run into a timeout while waiting for cert renewal[1]. [1] https://github.com/NixOS/nixpkgs/pull/81371#issuecomment-605526099
* Merge pull request #81369 from mweinelt/pr/acme-chmodSilvan Mosberger2020-03-07
|\ | | | | nixos/acme: apply chmod and ownership unconditionally
| * nixos/acme: apply chmod and ownership unconditionallyMartin Weinelt2020-02-29
| | | | | | | | | | | | | | Also separate directory and file permissions so the certificate files don't end up with the executable bit. Fixes #81335
* | nixos/acme: force symlink from fullchain.pem to cert.pemYegor Timoshenko2020-03-04
| | | | | | | | Co-authored-by: emily <vcs@emily.moe>
* | Merge pull request #80900 from emilazy/acme-must-stapleYegor Timoshenko2020-03-03
|\ \ | | | | | | nixos/acme: Must-Staple and extra flags
| * | nixos/acme: add extraLegoRenewFlags optionEmily2020-02-29
| | |
| * | nixos/acme: add ocspMustStaple optionEmily2020-02-29
| | |
* | | Merge pull request #80856 from emilazy/adjust-acmeYegor Timoshenko2020-03-03
|\ \ \ | | | | | | | | nixos/acme: adjust renewal timer options
| * | | nixos/acme: adjust renewal timer optionsEmily2020-02-29
| |/ / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current weekly setting causes every NixOS server to try to renew its certificate at midnight on the dot on Monday. This contributes to the general problem of periodic load spikes for Let's Encrypt; NixOS is probably not a major contributor to that problem, but we can lead by example by picking good defaults here. The values here were chosen after consulting with @yuriks, an SRE at Let's Encrypt: * Randomize the time certificates are renewed within a 24 hour period. * Check for renewal every 24 hours, to ensure the certificate is always renewed before an expiry notice is sent out. * Increase the AccuracySec (thus lowering the accuracy(!)), so that systemd can coalesce the renewal with other timers being run. (You might be worried that this would defeat the purpose of the time skewing, but systemd is documented as avoiding this by picking a random time.)
* | / nixos/acme: renew after rebuild and on bootMartin Weinelt2020-02-29
| |/ |/| | | | | Fixes #81069
* | nixos/acme: move the crt to fullchain.pemEmily2020-02-23
|/ | | | | | | | | | | lego already bundles the chain with the certificate,[1] so the current code, designed for simp_le, was resulting in duplicate certificate chains, manifesting as "Chain issues: Incorrect order, Extra certs" on the Qualys SSL Server Test. cert.pem stays around as a symlink for backwards compatibility. [1] https://github.com/go-acme/lego/blob/5cdc0002e9abb2463fffc962dadc3479f72d7486/acme/api/certificate.go#L40-L44
* nixos/acme: Fix b.example.com testLucas Savva2020-02-09
|
* nixos/acme: add dns-01 test, fix cert locating bugLucas Savva2020-02-09
|
* nixos/acme: simplify email resolve logicLucas Savva2020-02-03
|
* nixos/acme: fix some descriptions, default acceptTerms to falseLucas Savva2020-01-19
|
* nixos/acme: ignore tmpfiles rules for null webrootsLucas Savva2020-01-15
|
* nixos/acme: Add logic to select right email addressLucas Savva2020-01-12
|
* nixos/acme: replace simp-le with lego clientLucas Savva2020-01-12
| | | | | | | | | | | | | | | | | | | | | | Lego allows users to use the DNS-01 challenge to validate their certificates. It is mostly backwards compatible, with a few caveats. - extraDomains can no longer have different webroots to the main webroot for the cert. - An email address is now mandatory for account creation The following other changes were required: - Deprecate security.acme.certs.<name>.plugins, as this was specific to simp-le - Rename security.acme.validMin to validMinDays, to avoid confusion and errors. Lego requires the TTL to be specified in days - Add options to cover DNS challenge (dnsProvider, credentialsFile, dnsPropagationCheck) - A shared state directory is now used (/var/lib/acme/.lego) to avoid account creation rate limits and share credentials between certs
* nixos/acme: implement postRun using ExecStartPostBen Price2019-12-19
| | | | | | | | | In 5532065d0690645f0a813fed6e68163b0f4774d4, acme was changed to be RemainAfterExit=true, but `postRun` commands are implemented as `ExecStopPost`. Systemd now considers the service to be still running after simp_le is finished, so won't run these commands (e.g. to reload certificates in a webserver). Change `postRun` to use `ExecStartPost` to ensure the commands are run in a timely manner.
* nixos/treewide: Move rename.nix imports to their respective modulesSilvan Mosberger2019-12-10
| | | | | | | | A centralized list for these renames is not good because: - It breaks disabledModules for modules that have a rename defined - Adding/removing renames for a module means having to find them in the central file - Merge conflicts due to multiple people editing the central file
* nixos/acme: Fix allowKeysForGroup not applying immediately (#72056)Silvan Mosberger2019-11-13
|\ | | | | nixos/acme: Fix allowKeysForGroup not applying immediately
| * nixos/acme: Fix allowKeysForGroup not applying immediatelySilvan Mosberger2019-10-27
| | | | | | | | | | | | | | | | | | | | | | | | | | Previously setting `allowKeysForGroup = true; group = "foo"` would not apply the group permission change of the certificates until the service gets restarted. This commit fixes this by making systemd restart the service every time it changes. Note that applying this commit to a system with an already running acme systemd service doesn't fix this immediately and you still need to wait for the next refresh (or call `systemctl restart acme-<domain>`). Once everybody's service has restarted once this should be a problem of the past.
* | nixos/modules/security/acme.nix: add server optionFélix Baylac-Jacqué2019-10-30
| | | | | | | | | | | | | | | | Add a new option permitting to point certbot to an ACME Directory Resource URI other than Let's Encrypt production/staging one. In the meantime, we are deprecating the now useless Let's Encrypt production flag.
* | nixos/acme: fix staging endpoint urlFranz Pletz2019-10-28
|/ | | | fixes #72067
* nixos/tests/letsencrypt: use Pebble instead of BoulderFélix Baylac-Jacqué2019-10-23
| | | | | | | | | | | | | | | Let's encrypt bumped ACME to V2. We need to update our nixos test to be compatible with this new protocol version. We decided to drop the Boulder ACME server in favor of the more integration test friendly Pebble. - overriding cacert not necessary - this avoids rebuilding lots of packages needlessly - nixos/tests/acme: use pebble's ca for client tests - pebble always generates its own ca which has to be fetched TODO: write proper commit msg :)
* certbot: 0.31.0 -> 0.39.0Félix Baylac-Jacqué2019-10-23
| | | | | | | | | | | Updating: - nixos module to use the new `account_reg.json` file. - use nixpkgs pebble for integration tests. Co-authored-by: Florian Klink <flokli@flokli.de> Replace certbot-embedded pebble
* Merge staging-next into stagingFrederik Rietdijk2019-08-31
|\
| * Fix letsencrypt (#60219)Arian van Putten2019-08-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * nixos/acme: Fix ordering of cert requests When subsequent certificates would be added, they would not wake up nginx correctly due to target units only being triggered once. We now added more fine-grained systemd dependencies to make sure nginx always is aware of new certificates and doesn't restart too early resulting in a crash. Furthermore, the acme module has been refactored. Mostly to get rid of the deprecated PermissionStartOnly systemd options which were deprecated. Below is a summary of changes made. * Use SERVICE_RESULT to determine status This was added in systemd v232. we don't have to keep track of the EXITCODE ourselves anymore. * Add regression test for requesting mutliple domains * Deprecate 'directory' option We now use systemd's StateDirectory option to manage create and permissions of the acme state directory. * The webroot is created using a systemd.tmpfiles.rules rule instead of the preStart script. * Depend on certs directly By getting rid of the target units, we make sure ordering is correct in the case that you add new certs after already having deployed some. Reason it broke before: acme-certificates.target would be in active state, and if you then add a new cert, it would still be active and hence nginx would restart without even requesting a new cert. Not good! We make the dependencies more fine-grained now. this should fix that * Remove activationDelay option It complicated the code a lot, and is rather arbitrary. What if your activation script takes more than activationDelay seconds? Instead, one should use systemd dependencies to make sure some action happens before setting the certificate live. e.g. If you want to wait until your cert is published in DNS DANE / TLSA, you could create a unit that blocks until it appears in DNS: ``` RequiredBy=acme-${cert}.service After=acme-${cert}.service ExecStart=publish-wait-for-dns-script ```
* | treewide: remove redundant quotesvolth2019-08-26
|/
* acme module: fix self-signed cert with openssl 1.1Robin Gloster2018-09-12
|
* [bot]: remove unreferenced codevolth2018-07-20
|
* nixos/acme: Fix broken post-stop scriptBen Gamari2018-04-29
| | | | | | Previously the script would contain an empty `if` block (which is invalid syntax) if both `data.activationDelay == null` and `data.postRun == ""`. Fix this by adding a no-op `true`.
* Fix incorrect mergeGregor Kleen2018-04-21
|
* Merge branch 'master' into feat/acme/delayMatthew Justin Bauer2018-04-21
|\
| * acme service: generate a CA for self-signed certificateNikolay Amiantov2018-04-17
| | | | | | | | | | | | | | | | | | | | | | This is needed because simp_le expects two certificates in fullchain.pem, leading to error: > Not enough PEM encoded messages were found in fullchain.pem; at least 2 were expected, found 1. We now create a CA and sign the key with it instead, providing correct fullchain.pem. Also cleanup service a bit -- use PATH and a private temporary directory (which is more suitable).
| * acme module: update for simp_le v0.8Wout Mertens2018-03-24
| | | | | | Hopefully fixes #37689
| * nixos/acme: Fix xml (#34683)Robert Schütz2018-02-06
| |
| * security.acme: default name value via module system (#34388)Joachim Schiele2018-02-06
| |
| * nixos/acme: configurable TOS hash (#33522)zimbatm2018-01-11
| | | | | | | | This hash tends to change and upstream simp_le doesn't seem to keep up with the changes.