Waqar Ahmed
Waqar Ahmed

Reputation: 1444

How to support TLS 1.1, 1.2 for Python (2.7)

I have developed an application in Python 2.7. But it only supports PROTOCOL_TLSv1. I have to somehow make it compatible with PROTOCOL_TLSv1_1 and PROTOCOL_TLSv1_2. I can't find any library or trick to do so. Is it necessary to upgrade the Python version?

Kindly guide me or help me find the better solution. Isn't there any out of the way solution?

Upvotes: 3

Views: 14820

Answers (1)

Richard Urban
Richard Urban

Reputation: 399

libopenssl1 and python 2.7.9 provided you can force ssl.SSLContext like :

import ssl, urllib2
ctx = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
response = urllib2.urlopen(url, context=ctx).read()

Upvotes: 4

Related Questions