【问题标题】:Flask admin s3 SSL error烧瓶管理员 s3 SSL 错误
【发布时间】:2017-12-06 21:36:49
【问题描述】:

我正在尝试使用几种不同的实现从 Flask Admin 将文件上传到 S3。在这两种情况下,我都会收到 SSL 错误。我尝试了一些我发现的东西,例如将其添加到配置中:

    S3_USE_HTTPS = False

我还更新了我在另一个线程上看到推荐的 certifi 包。我无法解决这个错误。知道我为什么会得到这个吗?

以下错误消息:

> File
> "/Users/kevin/dev/allstarrma/flask-env/lib/python3.6/site-packages/boto/connection.py",
> line 1071, in make_request
>     retry_handler=retry_handler)   File "/Users/kevin/dev/allstarrma/flask-env/lib/python3.6/site-packages/boto/connection.py",
> line 1030, in _mexe
>     raise ex   File "/Users/kevin/dev/allstarrma/flask-env/lib/python3.6/site-packages/boto/connection.py",
> line 943, in _mexe
>     request.body, request.headers)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
> line 1239, in request
>     self._send_request(method, url, body, headers, encode_chunked)   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
> line 1285, in _send_request
>     self.endheaders(body, encode_chunked=encode_chunked)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
> line 1234, in endheaders
>     self._send_output(message_body, encode_chunked=encode_chunked)   File
> "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
> line 1026, in _send_output
>     self.send(msg)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
> line 964, in send
>     self.connect()   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/http/client.py",
> line 1400, in connect
>     server_hostname=server_hostname)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
> line 407, in wrap_socket
>     _context=self, _session=session)   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
> line 814, in __init__
>     self.do_handshake()   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
> line 1068, in do_handshake
>     self._sslobj.do_handshake()   File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/ssl.py",
> line 689, in do_handshake
>     self._sslobj.do_handshake() ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:777)

【问题讨论】:

  • 注意这不会解决根本原因,但是您可以使用 PYTHONHTTPSVERIFY=0 调用 python 脚本,因此从命令行它看起来像 PYTHONHTTPSVERIFY=0 /path/to/script.py。 Python ssl 不应该再抱怨认证了。
  • 部署到heroku的时候呢?

标签: python amazon-web-services ssl flask boto3


【解决方案1】:

可以找到关于默认https验证的信息: https://www.python.org/dev/peps/pep-0476/

还有来自 Red Hat 的精彩文章。 https://access.redhat.com/articles/2039753现在是开放的,但如果在付费墙后面,我决定写下重点。

正如评论中所说,您可以使用 PYTHONHTTPSVERIFY=0 /path/to/script.py 调用您的 python 脚本

您还可以在文件/etc/python/cert-verification.cfg 中配置-默认行为并更改

[https]
verify=platform_default

[https]
verify=disable

如果您使用的是最新的 python 2.7,您也可以使用它来动态禁用证书验证。

import ssl
ssl._https_verify_certificates(0)

不幸的是 Python > 3.4(我尝试了 3.4.5 和 3.6.3)我找不到类似的功能。文档https://docs.python.org/3/library/ssl.html 中的结果相同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-04-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-08-11
    • 2015-09-17
    • 1970-01-01
    相关资源
    最近更新 更多