Enable TLS 1.2 on Mac OSX

2019-07-17 15:46发布

I am pulling my hair out trying to get a Django application working with Stripe on my local machine with OSX 10.12.3. The error I get when trying to run a test payment is:

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.

I successfully upgraded openssl using brew. When I run openssl version the output is:

OpenSSL 1.0.2k  26 Jan 2017

When I run which openssl the output is:

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

I found instructions on stack overflow that said to run brew link --force openssl. When I do that the error is:

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

Can anybody help me get this working?

2条回答
别忘想泡老子
2楼-- · 2019-07-17 16:13

For anyone using brew + pyenv + pyenv-virtualenv this is what fixed my issue with missing TLS 1.2 on my Mac:

# 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

Hope that's useful to someone someday.

查看更多
来,给爷笑一个
3楼-- · 2019-07-17 16:17

The problem’s in the Python environment and the solution to try seems to be the following:

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

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

That’s all assuming you’re running Python 2.7.9+. Earlier Python versions have no TLS 1.2 support.

查看更多
登录 后发表回答