Fix SSLError in django request to external API

So I have a couple sites made with django and never seen this type of error before.

this site presents data from a API, so I hooked the API up with

try:
   r = requests.post(url, data=json.dumps(dados), headers=headers, timeout=30)
except Timeout:
   raise EmptyResultSet(f'Erro API TIMEOUT')
if r.status_code == requests.codes.ok:
   search = r.json()
else:
   search = []

So, I hook he request with the API server, and check for a timeout so django sends me an e-mail about that (with the EmptyResultSet because the site can't display properly when no data is received) then, if the code is ok it gets the data, and if there is an error it sets search = [] which gets data from a cache later in the code

this snippet was working normally, but then my production server started receiving this error:

HTTPSConnectionPool(host='****', port=443): Max retries exceeded with url: /api/Site/Busca (Caused by SSLError(SSLError('No cipher can be selected.')))

host hidden for safety

So, in local machines the site runs just fine and the people behind the API said my server isn't blacklisted this time, so I don't know where to search for some solution. Django version is 3.2.14, requests is 2.28.1 and urllib3 is 1.26.11

Back to Top