From 1ae8b8cc4a9d1fa30f27b9782af9f208a46e07d4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 28 Aug 2018 15:06:07 -0700 Subject: [PATCH] modules/s_keys: Auto-generate dhparams on key init. --- modules/s_keys.cc | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/s_keys.cc b/modules/s_keys.cc index 5709fb77f..353a9ebe3 100644 --- a/modules/s_keys.cc +++ b/modules/s_keys.cc @@ -63,6 +63,12 @@ init_my_tls_crt() m::self::origin + ".crt.key.pub", }; + const std::string dhparam_path_parts[] + { + tls_key_dir, + m::self::origin + ".crt.dh", + }; + const std::string certificate_path_parts[] { tls_key_dir, @@ -79,6 +85,11 @@ init_my_tls_crt() fs::make_path(public_key_path_parts) }; + const std::string dhparam_file + { + fs::make_path(dhparam_path_parts) + }; + const std::string cert_file { fs::make_path(certificate_path_parts) @@ -95,6 +106,17 @@ init_my_tls_crt() openssl::genrsa(private_key_file, public_key_file); } + if(!fs::exists(dhparam_file)) + { + log::warning + { + "Failed to find dhparam file @ `%s'; creating; this will take a long time...", + dhparam_file + }; + + openssl::gendh(dhparam_file); + } + const json::object config{}; if(!fs::exists(cert_file)) {