简体   繁体   中英

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?

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()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM