Skip to content

Commit

Permalink
Use pregenerated DH params when generating config
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Haines committed Sep 1, 2014
1 parent bcfaaf7 commit 8b69468
Showing 1 changed file with 29 additions and 7 deletions.
36 changes: 29 additions & 7 deletions synapse/config/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
import subprocess
import os

GENERATE_DH_PARAMS=False


class TlsConfig(Config):
def __init__(self, args):
super(TlsConfig, self).__init__(args)
Expand Down Expand Up @@ -97,10 +100,29 @@ def generate_config(cls, args, config_dir_path):
certifcate_file.write(cert_pem)

if not os.path.exists(args.tls_dh_params_path):
subprocess.check_call([
"openssl", "dhparam",
"-outform", "PEM",
"-out", args.tls_dh_params_path,
"2048"
])

if GENERATE_DH_PARAMS:
subprocess.check_call([
"openssl", "dhparam",
"-outform", "PEM",
"-out", args.tls_dh_params_path,
"2048"
])
else:
with open(args.tls_dh_params_path, "w") as dh_params_file:
dh_params_file.write(
"2048-bit DH parameters taken from rfc3526\n"
"-----BEGIN DH PARAMETERS-----\n"
"MIIBCAKCAQEA///////////JD9qiIWjC"
"NMTGYouA3BzRKQJOCIpnzHQCC76mOxOb\n"
"IlFKCHmONATd75UZs806QxswKwpt8l8U"
"N0/hNW1tUcJF5IW1dmJefsb0TELppjft\n"
"awv/XLb0Brft7jhr+1qJn6WunyQRfEsf"
"5kkoZlHs5Fs9wgB8uKFjvwWY2kg2HFXT\n"
"mmkWP6j9JM9fg2VdI9yjrZYcYvNWIIVS"
"u57VKQdwlpZtZww1Tkq8mATxdGwIyhgh\n"
"fDKQXkYuNs474553LBgOhgObJ4Oi7Aei"
"j7XFXfBvTFLJ3ivL9pVYFxg5lUl86pVq\n"
"5RXSJhiY+gUQFXKOWoqsqmj/////////"
"/wIBAg==\n"
"-----END DH PARAMETERS-----\n"
)

0 comments on commit 8b69468

Please sign in to comment.