SSLError: Can't connect to HTTPS URL because the SSL module is not available on google app engine

天大地大妈咪最大 提交于 2019-11-30 11:03:18

If you're using GAE's Sockets, you can get SSL support without any hacks by simply loading the SSL library.

Simply add this to your app.yaml file:

libraries:
- name: ssl
  version: latest

This is documented on Google Cloud's OpenSSL Support documentation.

This blog post details a solution. From the blog post:

The problem is GAE has a “whitelist” of select standard libraries. SSL (_ssl, _socket) is not one of them. So, we need to tweak the sandbox environment (dangerous) carefully. The below code uses the standard Python socket library instead of the GAE-provided in the development environment. Modify [or create] appengine_config.py:

import os

# Workaround the dev-environment SSL
#   http://stackoverflow.com/q/16192916/893652
if os.environ.get('SERVER_SOFTWARE', '').startswith('Development'):
    import imp
    import os.path
    from google.appengine.tools.devappserver2.python import sandbox

    sandbox._WHITE_LIST_C_MODULES += ['_ssl', '_socket']
    # Use the system socket.
    psocket = os.path.join(os.path.dirname(os.__file__), 'socket.py')
    imp.load_source('socket', psocket)

Jan Dolejsi,

If you're using GAE's Sockets, you can get SSL support without any hacks by simply loading the SSL library.

Simply add this to your app.yaml file:

libraries: - name: ssl
- version: latest

If you're experiencing RAND_egd error, just change "-version: latest" in your app.yaml, to "-version: 2.7"!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!