[英]Braintree SDK SSLCertificateError on AppEngine local dev server
The use of Braintree SDK under my local dev_appserver.py
is returning following error on braintree.ClientToken.generate()
: 在我的本地
dev_appserver.py
下使用Braintree SDK在Braintree.ClientToken.generate braintree.ClientToken.generate()
上返回以下错误:
SSLError: SSLCertificateError:
Invalid and/or missing SSL certificate for URL:
https://api.sandbox.braintreegateway.com:443/merchants/<merchant_id>/client_token
I am using the requests_toolbelt
at the start of my server: 我在服务器启动时使用了
requests_toolbelt
:
# Make requests work in GAE
import requests
from requests_toolbelt.adapters import appengine
appengine.monkeypatch()
Explicitly excluding SSL Validation doesn't work either (returns with the same error message): 明确排除SSL验证也不起作用(返回相同的错误消息):
appengine.monkeypatch(validate_certificate=False)
In fact, without requests_toolbelt
, the error I get when calling .generate()
is: 事实上,如果没有
requests_toolbelt
,错误,我得到的时候调用.generate()
是:
ProtocolError('Connection aborted.', error(13, 'Permission denied'))
I also tried the hack in the main.py
of braintree-python-appengine project but I get the same SSL error message back. 我还尝试了braintree-python-appengine项目的
main.py
中的hack,但是我得到了相同的SSL错误消息。
requests
on https://www.braintreepayments.com/
returns 200 without any errors https://www.braintreepayments.com/
上使用requests
将返回200,没有任何错误 Braintree support kindly replied to my inquiry with (on 2017-11-20): Braintree支持人员于(2017-11-20)回复了我的询问:
The error you're receiving is generally related to the SSL/TLS protocols being used when your app is run;
您收到的错误通常与应用程序运行时使用的SSL / TLS协议有关; our sandbox environment requires connections to be made via TLS 1.2, a requirement that does not yet apply to production.
我们的沙盒环境要求通过TLS 1.2建立连接,该要求尚未应用于生产。
From review, it appears that the protocols being used when the app is deployed locally are not valid for our environment.
经审查,看来在本地部署应用程序时使用的协议对我们的环境无效。 If the app settings are localised within the Google App Engine, that may be the cause of the issue;
如果应用设置在Google App Engine中进行了本地化,则可能是造成此问题的原因; Python uses the system-supplied OpenSSL, and TLSv1.2 requires OpenSSL 1.0.1c or later.
Python使用系统提供的OpenSSL,而TLSv1.2需要OpenSSL 1.0.1c或更高版本。
So the root cause is my version of Python which uses an older version of OpenSSL: 因此,根本原因是我的Python版本使用了较旧的OpenSSL版本:
$ python --version
Python 2.7.10
$ python
>> import ssl
>> ssl.OPENSSL_VERSION
>> 'OpenSSL 0.9.8zh 14 Jan 2016'
The solution is to upgrade my version of python via brew: 解决方案是通过brew升级我的python版本:
$ brew install python
$ python2 --version
Python 2.7.14
$ python2
>> import ssl
>> ssl.OPENSSL_VERSION
>> 'OpenSSL 1.0.2m 2 Nov 2017'
Then, launching my dev server using newly installed python solves the SSLCertificateError
: 然后,使用新安装的python启动我的开发服务器即可解决
SSLCertificateError
:
python2 $appserver_path/dev_appserver.py ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.