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

后端 未结 3 1913
北荒
北荒 2021-01-01 14:37

Want to use wechat sdk to create menu

WeChat.create_menu({
     \"button\":[
     {    
          \"type\":\"click\",
          \"name\":\"Daily Song\",
            


        
相关标签:
3条回答
  • 2021-01-01 15:07

    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.

    0 讨论(0)
  • 2021-01-01 15:17

    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"!

    0 讨论(0)
  • 2021-01-01 15:23

    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)
    
    0 讨论(0)
提交回复
热议问题