|
1 | 1 | import sys |
| 2 | +from ssl import SSLContext |
2 | 3 | from typing import Any, Optional, Iterable |
3 | 4 |
|
4 | 5 | from httpie.cookies import HTTPieCookiePolicy |
5 | | -from http import cookiejar # noqa |
| 6 | +from http import cookiejar # noqa |
6 | 7 |
|
7 | 8 |
|
8 | 9 | # Request does not carry the original policy attached to the |
9 | 10 | # cookie jar, so until it is resolved we change the global cookie |
10 | 11 | # policy. <https://github.com/psf/requests/issues/5449> |
11 | 12 | cookiejar.DefaultCookiePolicy = HTTPieCookiePolicy |
12 | 13 |
|
13 | | - |
14 | 14 | is_windows = 'win32' in str(sys.platform).lower() |
15 | 15 | is_frozen = getattr(sys, 'frozen', False) |
16 | 16 |
|
@@ -66,7 +66,6 @@ def __get__(self, instance, cls=None): |
66 | 66 | res = instance.__dict__[self.name] = self.func(instance) |
67 | 67 | return res |
68 | 68 |
|
69 | | - |
70 | 69 | # importlib_metadata was a provisional module, so the APIs changed quite a few times |
71 | 70 | # between 3.8-3.10. It was also not included in the standard library until 3.8, so |
72 | 71 | # we install the backport for <3.8. |
@@ -100,3 +99,15 @@ def get_dist_name(entry_point: importlib_metadata.EntryPoint) -> Optional[str]: |
100 | 99 | return None |
101 | 100 | else: |
102 | 101 | return metadata.get('name') |
| 102 | + |
| 103 | + |
| 104 | +def ensure_default_certs_loaded(ssl_context: SSLContext) -> None: |
| 105 | + """ |
| 106 | + Workaround for a bug in Requests 2.32.3 |
| 107 | +
|
| 108 | + See <https://github.com/httpie/cli/issues/1583> |
| 109 | +
|
| 110 | + """ |
| 111 | + if hasattr(ssl_context, 'load_default_certs'): |
| 112 | + if not ssl_context.get_ca_certs(): |
| 113 | + ssl_context.load_default_certs() |
0 commit comments