Serving Flask app with waitress on windows using SSL public/private key

11.8k views Asked by At

How do I run my Flask app which uses SSL keys using waitress. The SSL context is specified in my Flask's run() as in

                       app.run(ssl_context=('cert.pem', 'key.pem'))

But app.run() is not used when using waitress as in the code below. So, where do I specify the keys? Thanks for the help.

   from flask import Flask, request
   app = Flask(__name__)

   @app.route("/")
   def hello():
       return "Hello World!"

  if __name__ == '__main__':
  #   app.run(ssl_context=('../cert.pem', '../key.pem'))
      from waitress import serve
      serve(app, host="0.0.0.0", port=5000)
1

There are 1 answers

2
JBLaf On BEST ANSWER

At the current version (1.4.3), Waitress does not natively support TLS.

See TLS support in https://github.com/Pylons/waitress/blob/36240c88b1c292d293de25fecaae1f1d0ad9cc22/docs/reverse-proxy.rst

You either need a reverse proxy in front to handle the tls/ssl part, or use another WSGI server (CherryPy, Tornado...).