SSL and WSGI Applications - Python

I have a WSGI application that I would like to host for SSL. My WSGI gevent server .

How could you support the application over SSL in this case?

+3
source share
3 answers

It looks like gevent now has an ssl module. If you have a web server implemented on top of gevent, I assume that you can change it to associate incoming connections with this class of the module ssl class before passing it to http handlers.

http://blog.gevent.org/2010/02/05/version-0-12-0-released/

http://www.gevent.org/gevent.ssl.html

apache + mod_wsgi wsgi.

+3

gevent.wsgi SSL. , nginx, HTTPS, - gevent-, HTTP.

gevent.pywsgi SSL . keyfile certfile, SSL. : wsgiserver_ssl.py:

#!/usr/bin/python
"""Secure WSGI server example based on gevent.pywsgi"""

from __future__ import print_function
from gevent import pywsgi


def hello_world(env, start_response):
    if env['PATH_INFO'] == '/':
        start_response('200 OK', [('Content-Type', 'text/html')])
        return [b"<b>hello world</b>"]
    else:
        start_response('404 Not Found', [('Content-Type', 'text/html')])
        return [b'<h1>Not Found</h1>']

print('Serving on https://127.0.0.1:8443')
server = pywsgi.WSGIServer(('0.0.0.0', 8443), hello_world, keyfile='server.key', certfile='server.crt')
# to start the server asynchronously, call server.start()
# we use blocking serve_forever() here because we have no other jobs
server.serve_forever()
+5

I would allow the http server to handle the ssl transport.

+2
source

Source: https://habr.com/ru/post/1745977/


All Articles