Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dovecot2: configure dhparams generation for ssl_dh #39288

Closed
wants to merge 1 commit into from

Conversation

mkaito
Copy link
Contributor

@mkaito mkaito commented Apr 20, 2018

With v2.3 you are required to provide ssl_dh=</path/to/dh.pem yourself.

Generating Diffie Hellman params takes a lot of entropy, but I'm
hesitant to just enable haveged as well for everyone.

Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option build-use-sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

With v2.3 you are required to provide ssl_dh=</path/to/dh.pem yourself.
@mkaito
Copy link
Contributor Author

mkaito commented Apr 20, 2018

As far as I can tell, it works. Deployed it on my mail server.

@Mic92
Copy link
Member

Mic92 commented Apr 21, 2018

We have systemd-random-seed.service to hopefully circumvent this. Might be only not available on the first early boot.

@Mic92
Copy link
Member

Mic92 commented Apr 21, 2018

cc @fpletz

@qknight
Copy link
Member

qknight commented Apr 25, 2018

@mkaito please have a look at #39507 and either use mine or adapt your PR. i'm fine with both.

please backport either the fixed patch (yours) or mine to 18.03 while also merge it into nixpkgs master. thanks!

aszlig added a commit to aszlig/nixpkgs that referenced this pull request Apr 26, 2018
This option allows us to turn off stateful generation of Diffie-Hellman
parameters, which in some way is still stateful as the generated DH
params file is non-deterministic.

However what we can avoid with this is to have an increased surface for
failures during system startup, because generation of the parameters is
done during build-time.

Another advantage of this is that we no longer need to take care of
cleaning up the files that are no longer used and in my humble opinion I
would have preferred that NixOS#11505 (which puts the dhparams in the Nix
store) would have been merged instead of NixOS#22634 (which we have now).

Luckily we can still change that and this change gives the user the
option to put the dhparams into the Nix store.

Beside of the more obvious advantages pointed out here, this also
effects test runtime if more services are starting to use this (for
example see NixOS#39507 and NixOS#39288), because generating DH params could take
a long time depending on the bit size which adds up to test runtime.

If we generate the DH params in a separate derivation, subsequent test
runs won't need to wait for DH params generation during bootup.

Of course, tests could still mock this by force-disabling the service
and adding a service or activation script that places pre-generated DH
params in /var/lib/dhparams but this would make tests less readable and
the workaround would have to be made for each test affected.

Note that the 'stateful' option is still true by default so that we are
backwards-compatible with existing systems.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Ekleog, @abbradar, @fpletz
@abbradar
Copy link
Member

I'm going to go with @qknight 's PR for now -- yours generates dhparams unconditionally. Also you don't need to add requires or before to dovecot2.service -- dhparams unit makes itself running before service with the same name as the param automatically.

@mkaito
Copy link
Contributor Author

mkaito commented May 2, 2018

Sure, works for me.

@mkaito mkaito closed this May 2, 2018
globin pushed a commit to mayflower/nixpkgs that referenced this pull request May 24, 2018
This option allows us to turn off stateful generation of Diffie-Hellman
parameters, which in some way is still stateful as the generated DH
params file is non-deterministic.

However what we can avoid with this is to have an increased surface for
failures during system startup, because generation of the parameters is
done during build-time.

Another advantage of this is that we no longer need to take care of
cleaning up the files that are no longer used and in my humble opinion I
would have preferred that NixOS#11505 (which puts the dhparams in the Nix
store) would have been merged instead of NixOS#22634 (which we have now).

Luckily we can still change that and this change gives the user the
option to put the dhparams into the Nix store.

Beside of the more obvious advantages pointed out here, this also
effects test runtime if more services are starting to use this (for
example see NixOS#39507 and NixOS#39288), because generating DH params could take
a long time depending on the bit size which adds up to test runtime.

If we generate the DH params in a separate derivation, subsequent test
runs won't need to wait for DH params generation during bootup.

Of course, tests could still mock this by force-disabling the service
and adding a service or activation script that places pre-generated DH
params in /var/lib/dhparams but this would make tests less readable and
the workaround would have to be made for each test affected.

Note that the 'stateful' option is still true by default so that we are
backwards-compatible with existing systems.

Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Ekleog, @abbradar, @fpletz
(cherry picked from commit 3e11ff6)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants