From c8df9355f0501567f6712d750ae1e6cc5fec82bc Mon Sep 17 00:00:00 2001 From: Bastian Kleineidam Date: Fri, 5 Sep 2014 20:00:30 +0200 Subject: [PATCH] Try to use the SSL certs from the certifi package. --- linkcheck/configuration/__init__.py | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/linkcheck/configuration/__init__.py b/linkcheck/configuration/__init__.py index 7ef00df0..f023230f 100644 --- a/linkcheck/configuration/__init__.py +++ b/linkcheck/configuration/__init__.py @@ -116,6 +116,21 @@ def get_share_file (filename, devel_dir=None): raise ValueError(msg) +def get_certifi_file(): + """Get the SSL certifications installed by the certifi package. + @return: the filename to the cert file + @rtype: string + @raises: ImportError when certifi is not installed or ValueError when + the file is not found + """ + import certifi + filename = certifi.where() + if os.path.isfile(filename): + return filename + msg = "%s not found; check your certifi installation" % filename + raise ValueError(msg) + + # dynamic options class Configuration (dict): """ @@ -320,7 +335,10 @@ class Configuration (dict): try: self["sslverify"] = get_share_file('cacert.pem') except ValueError: - pass + try: + self["sslverify"] = get_certifi_file() + except ImportError: + pass def get_plugin_folders():