6

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)
Morey
  • 549
  • 7
  • 10

1 Answers1

7

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...).

JBLaf
  • 776
  • 5
  • 10
  • 1
    Any idea if this has changed or do we still need to use a reverse proxy? – pee2pee Jul 07 '22 at 09:50
  • 1
    I believe it is the same (no change in documentation : https://docs.pylonsproject.org/projects/waitress/en/latest/reverse-proxy.html#using-behind-a-reverse-proxy) – JBLaf Jul 10 '22 at 07:46