Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python/Requests: requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE]

In Python using MacOS X, made an attempt to make a POST request to a website but I got the following error post_response = session.post(post_url, data=post_payload, headers=post_headers):

Traceback (most recent call last):
  File "web_requests.py", line 424, in <module>
    main()
  File "web_requests.py", line 340, in main
    post_response = session.post(post_url, data=post_payload, headers=post_headers)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 535, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 488, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 609, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/adapters.py", line 497, in send
    raise SSLError(e, request=request)
requests.exceptions.SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:590)

What could be the issue?

Thank you in advance and will be sure to upvote/accept answer

EDIT

Specific to POST requests in Python

like image 838
Jo Ko Avatar asked Apr 19 '26 09:04

Jo Ko


1 Answers

According to the addititional information in the comment SSLLabs reports for this site that it support TLS 1.2 only:

TLS 1.2 Yes   
TLS 1.1 No   
TLS 1.0 No   
SSL 3   No 

And according to another information in the comments the OpenSSL version is 0.9.8:

.. OpenSSL 0.9.8zg 14 July 2015

Since OpenSSL 0.9.8 only support up to TLS 1.0 and especially not TLS 1.2 there is no common TLS protocol spoken between the client and the server. Thus, the handshake fails.

The way to fix the problem is to upgrade the version of OpenSSL as used by Python away from the very old version to at least OpenSSL 1.0.1. See for example Updating openssl in python 2.7 for more information or use Anaconda Python which comes preinstalled with a lot of modules and also includes a current version of OpenSSL.

like image 84
Steffen Ullrich Avatar answered Apr 21 '26 23:04

Steffen Ullrich



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!