python - 在 macOS 上将 TLS 1.0 升级到 TLS 1.2
问题描述
我在安装一些我相信的 python 包时遇到了麻烦,因为我有 TLS 1.0 版本。如何升级到 TLS 1.2?
python -c "import urllib2; import json; print(json.loads(urllib2.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])"
TLS 1.0
我的 macOS 版本:10.13.4 (17E202)
python 版本:Python 2.7.13
openssl 版本:LibreSSL 2.2.7
我尝试升级 openssl,但它没有升级 LibreSSL。我记得一年前我在使用 openssl 时遇到了一些问题,我可能已经手动链接了它或其他东西:(
解决方案
即使 brew 下载了新版本的 openssl,旧版本与 command 一起使用openssl
。所以我禁用了 csrutil以摆脱 openssl 符号链接/usr/bin/openssl
:
sudo ln -s /usr/local/Cellar/openssl/1.0.2o_1/bin/openssl /usr/bin/openssl
然后 openssl 版本是最新的:
~ openssl version
OpenSSL 1.0.2o 27 Mar 2018
但是python仍然使用旧版本的openssl:
~ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 0.9.8zh 14 Jan 2016
所以要再次禁用 csrutil 并继续修复 python 版本。
我删除了我可以找到的python2安装,或多或少遵循以下内容:
brew uninstall python@2
sudo rm -rf /Library/Frameworks/Python.framework/Versions/2.7
sudo rm -rf "/Applications/Python 2.7"
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/2.7' | awk '{print $9}' | tr -d @ | xargs rm
然后我通过brew安装了python2,它使用了正确的openssl:
~ brew install python@2
~ python -c "import urllib2,json; print(json.loads(urllib2.urlopen('https://www.howsmyssl.com/a/check').read())['tls_version'])"
TLS 1.2
推荐阅读
- python - 嵌入字段中的 Discord Python Bot 多值
- r - 带有多个标签ggplot2的条形图
- ruby - 用户保存的数据使复选框的初始值
- javascript - 如何使用 axios 从 React-Native-Image-Picker 上传图像?
- sockets - boost::asio,async_receive_from 超时,当使用单个 Udp 套接字侦听多个端点时?
- python - PyDrive上传速度太慢
- javascript - 如何摆脱 SVG 图像上的边框?
- terraform - terraform init 期间的“变量可能不会在此处使用”
- common-lisp - 如何在 Lisp 中确定文件类型
- python - Python动态函数参数