在 Mac OSX 上启用 TLS 1.2

Enable TLS 1.2 on Mac OSX

我正在努力尝试让 Django 应用程序在我的本地机器上使用 Stripe 和 OSX 10.12.3。我在尝试 运行 测试付款时遇到的错误是:

PermissionError at /register Request req_ADIwntj3xGaqUF: Stripe no longer supports API requests made with TLS 1.0. Please initiate HTTPS connections with TLS 1.2 or later. You can learn more about this at https://stripe.com/blog/upgrading-tls.

我使用 brew 成功升级了 openssl。当我 运行 openssl version 输出是:

OpenSSL 1.0.2k  26 Jan 2017

当我运行 which openssl 输出是:

/usr/local/opt/openssl/bin/openssl

我找到了关于堆栈溢出的说明 运行 brew link --force openssl。当我这样做时,错误是:

Warning: Refusing to link: openssl Linking keg-only openssl means you may end up linking against the insecure, deprecated system OpenSSL while using the headers from Homebrew's openssl. Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

谁能帮我解决这个问题?

问题出在 Python 环境中,尝试的解决方案似乎如下:

pip install urllib3
pip install pyopenssl
pip install ndg-httpsclient
pip install pyasn1
pip uninstall requests
pip install requests

https://github.com/pinax/pinax-stripe/issues/267 and How to run django runserver over TLS 1.2

假设您是 运行 Python 2.7.9+。早期 Python 版本不支持 TLS 1.2。

对于使用 brew + pyenv + pyenv-virtualenv 的任何人,这是解决我 Mac 上缺少 TLS 1.2 的问题的原因:

# Update XCode 
# Restart machine
Type:
$ brew update
$ brew upgrade pyenv
$ pyenv install 3.4.6 # the latest version of Python 3.4
$ pyenv global 3.4.6  # make default python
$ pyenv virtualenv 3.4.6 myenv
$ pyenv activate myenv
$ pip install -r requirements.txt

希望有一天对某人有用。