How to check if your Python app supports TLS 1.2
As you may have already heard, the Payment Card Industry (PCI) will be requiring everyone to use at least TLS 1.1 (1.2 is recommended) to meet their data security standard starting on June 30, 2018. Other services, such as PyPI, will be requiring only TLS 1.2 connections on the same date as well.
You need to make sure that the version of Python you're using and related packages support TLS 1.2 or a bunch of things could break. If your app connects to APIs, they may enforce this as well. Shopify, for example, will be requiring all apps to use TLS 1.2 when connecting to their APIs this month as they have to comply with the PCI standard.
You can run the commands below to make sure your version of Python and related packages support it. They should output "TLS 1.2" if you're on that version.
Test with the "requests" package
Python 2
python -c "import requests; print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])"
Python 3
python3 -c "import requests; print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version'])"
Test with the "urllib" package
Python 2
python -c "import json, urllib2; print json.load(urllib2.urlopen('https://www.howsmyssl.com/a/check'))['tls_version']"
Python 3
python3 -c "import json, urllib.request; print(json.loads(urllib.request.urlopen('https://www.howsmyssl.com/a/check').read().decode('UTF-8'))['tls_version'])"
In my specific case, since I use Django for most of my projects. I ran the following in the Django shell as well to be sure (Python 3):
python manage.py shell
import requests print(requests.get('https://www.howsmyssl.com/a/check', verify=False).json()['tls_version']) import json import urllib.request print(json.loads(urllib.request.urlopen('https://www.howsmyssl.com/a/check').read().decode('UTF-8'))['tls_version'])
Sources: