Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- from requests.adapters import HTTPAdapter
- from requests.packages.urllib3.util.ssl_ import create_urllib3_context
- # https://stackoverflow.com/questions/40373115/how-to-select-specific-the-cipher-while-sending-request-via-python-request-modul
- CIPHERS = (
- 'ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+HIGH:'
- 'DH+HIGH:RSA+AESGCM:RSA+AES:RSA+HIGH:!aNULL:!eNULL:!MD5:GOST2012-GOST8912-GOST8912'
- )
- class GOSTAdapter(HTTPAdapter):
- def init_poolmanager(self, *args, **kwargs):
- context = create_urllib3_context(ciphers=CIPHERS)
- kwargs['ssl_context'] = context
- return super(GOSTAdapter, self).init_poolmanager(*args, **kwargs)
- def proxy_manager_for(self, *args, **kwargs):
- context = create_urllib3_context(ciphers=CIPHERS)
- kwargs['ssl_context'] = context
- return super(GOSTAdapter, self).proxy_manager_for(*args, **kwargs)
- s = requests.Session()
- s.verify = '/etc/ssl/certs/ca-certificates.crt'
- s.mount('https://somegostsite', GOSTAdapter())
- r = s.get('https://somegostsite')
- print(r.text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement