From 34e469eb558cae999b13510b029714a31d9dd1f3 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Tue, 11 Mar 2014 20:23:27 +0100 Subject: [PATCH] create dhparam file if it doesn't exist, fix mitmproxy/mitmproxy#235 --- netlib/certutils.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/netlib/certutils.py b/netlib/certutils.py index 92b219ee6..ebe643e46 100644 --- a/netlib/certutils.py +++ b/netlib/certutils.py @@ -123,6 +123,13 @@ class CertStore: @classmethod def load_dhparam(klass, path): + + # netlib<=0.10 doesn't generate a dhparam file. + # Create it now if neccessary. + if not os.path.exists(path): + with open(path, "wb") as f: + f.write(DEFAULT_DHPARAM) + bio = OpenSSL.SSL._lib.BIO_new_file(path, b"r") if bio != OpenSSL.SSL._ffi.NULL: bio = OpenSSL.SSL._ffi.gc(bio, OpenSSL.SSL._lib.BIO_free)