mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-28 15:48:16 +00:00
Search for system certs
This commit is contained in:
parent
30059732f2
commit
697e7b82e1
1 changed files with 22 additions and 4 deletions
|
|
@ -116,6 +116,19 @@ def get_share_file (filename, devel_dir=None):
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
|
|
||||||
|
def get_system_cert_file():
|
||||||
|
"""Try to find a system-wide SSL certificate file.
|
||||||
|
@return: the filename to the cert file
|
||||||
|
@raises: ValueError when no system cert file could be found
|
||||||
|
"""
|
||||||
|
if os.name == 'posix':
|
||||||
|
filename = "/etc/ssl/certs/ca-certificates.crt"
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
return filename
|
||||||
|
msg = "no system certificate file found"
|
||||||
|
raise ValueError(msg)
|
||||||
|
|
||||||
|
|
||||||
def get_certifi_file():
|
def get_certifi_file():
|
||||||
"""Get the SSL certifications installed by the certifi package.
|
"""Get the SSL certifications installed by the certifi package.
|
||||||
@return: the filename to the cert file
|
@return: the filename to the cert file
|
||||||
|
|
@ -330,15 +343,20 @@ class Configuration (dict):
|
||||||
self[plugin] = {}
|
self[plugin] = {}
|
||||||
|
|
||||||
def sanitize_ssl(self):
|
def sanitize_ssl(self):
|
||||||
"""Use locally installed certificate file if available."""
|
"""Use local installed certificate file if available.
|
||||||
|
Tries to get system, then certifi, then the own
|
||||||
|
installed certificate file."""
|
||||||
if self["sslverify"] is True:
|
if self["sslverify"] is True:
|
||||||
try:
|
try:
|
||||||
self["sslverify"] = get_share_file('cacert.pem')
|
self["sslverify"] = get_system_cert_file()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
try:
|
try:
|
||||||
self["sslverify"] = get_certifi_file()
|
self["sslverify"] = get_certifi_file()
|
||||||
except ImportError:
|
except (ValueError, ImportError):
|
||||||
pass
|
try:
|
||||||
|
self["sslverify"] = get_share_file('cacert.pem')
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def get_plugin_folders():
|
def get_plugin_folders():
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue