Search code examples
pythonhttpsslpython-requests

Getting the error "SSLError(SSLError(1, '[SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:1002)'))" using Python library Requests


I'm trying to make a GET request to URL https://si3.ufc.br using Python requests lib:

import requests

r = requests.get('https://si3.ufc.br/', verify=False)

print(r)

But I'm getting the following error:

requests.exceptions.SSLError: HTTPSConnectionPool(host='si3.ufc.br', port=443): Max retries exceeded with url: /sigaa/public/home.jsf (Caused by SSLError(SSLError(1, '[SSL: WRONG_SIGNATURE_TYPE] wrong signature type (_ssl.c:1002)')))

Already tryed to set parameter "verify" to False, but it didn't change. Also tryed, as recomended in other answer, to set:

requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'DEFAULT@SECLEVEL=1'

But didn't work either.

To other URLs, it's working fine, but i need to access that one. I expected to get response with status code 200.


Solution

  • For this site, set AES128-SHA256 cipher:

    import ssl
    
    import requests
    
    
    class TLSAdapter(requests.adapters.HTTPAdapter):
        def init_poolmanager(self, *args, **kwargs):
            ctx = ssl.create_default_context()
            ctx.set_ciphers("AES128-SHA256")
            kwargs["ssl_context"] = ctx
            return super(TLSAdapter, self).init_poolmanager(*args, **kwargs)
    
    
    url = "https://si3.ufc.br"
    
    with requests.session() as s:
        s.mount("https://", TLSAdapter())
        print(s.get(url))
    

    Prints:

    <Response [200]>
    

    For future reference: you can go to https://www.ssllabs.com/ssltest/analyze.html?d=si3.ufc.br and at the end of the page you see Handshake Simulation (and ciphers which succeeded - you can try to set these ciphers explicitly in ssl):

    enter image description here