-
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
8 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
# Ciphers compatible with SAT Services | ||
import ssl | ||
|
||
import certifi | ||
from requests.adapters import HTTPAdapter | ||
from urllib3.util import create_urllib3_context | ||
|
||
CIPHERS = ( | ||
'ECDHE+AESGCM:ECDHE+CHACHA20:DHE+AESGCM:DHE+CHACHA20:ECDH+AESGCM:' | ||
'DH+AESGCM:ECDH+AES:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!eNULL:!MD5:!DSS' | ||
':HIGH:!DH' | ||
) | ||
|
||
ssl_context = ssl.create_default_context(cafile=certifi.where()) | ||
ssl_context.set_ciphers(CIPHERS) | ||
|
||
|
||
class SSLAdapter(HTTPAdapter): | ||
def init_poolmanager(self, *args, **kwargs): | ||
kwargs['ssl_context'] = create_urllib3_context(ciphers=CIPHERS) | ||
kwargs['ssl_context'] = ssl_context | ||
return super().init_poolmanager(*args, **kwargs) | ||
|
||
def proxy_manager_for(self, *args, **kwargs): | ||
kwargs['ssl_context'] = create_urllib3_context(ciphers=CIPHERS) | ||
kwargs['ssl_context'] = ssl_context | ||
return super().proxy_manager_for(*args, **kwargs) |