Debian Codegraph @

httplib2/certs.py

raw ◀ ▶
1 Debian patch touch this file
1 """Utilities for certificate management."""
2
3 import os
4
5 certifi_available = False
6 certifi_where = None
7 try:
8 from certifi import where as certifi_where
9 certifi_available = True
10 except ImportError:
11 pass
12
13 custom_ca_locater_available = False
14 custom_ca_locater_where = None
15 try:
16 from ca_certs_locater import get as custom_ca_locater_where
17 custom_ca_locater_available = True
18 except ImportError:
19 pass
20
21
•22 BUILTIN_CA_CERTS = "/etc/ssl/certs/ca-certificates.crt"
23
24
25 def where():
26 env = os.environ.get("HTTPLIB2_CA_CERTS")
27 if env is not None:
28 if os.path.isfile(env):
29 return env
30 else:
31 raise RuntimeError("Environment variable HTTPLIB2_CA_CERTS not a valid file")
32 if custom_ca_locater_available:
33 return custom_ca_locater_where()
34 if certifi_available:
35 return certifi_where()
36 return BUILTIN_CA_CERTS
37
38
39 if __name__ == "__main__":
40 print(where())