How should I translate app.run() to sockio.run() with SSL?
I have below app start code to run with flask development server
if __name__=='__main__':
app.run(ssl_context=(ssl_cert, ssl_key))
I am now trying to start it with socketio like below
if __name__=='__main__':
socketio.run(app, host='0.0.0.0', port=80, debug=True)
However, I cannot figure out how to pass cert into this call.
What do I have to do to make this work?
I was having the same issue. This is equivalent to what worked for me.
if __name__ == '__main__':
socketio.run(app, host="0.0.0.0", port="80", debug=True, ssl_context=('cert.pem', 'key.pem'))
For some reason I had to manually enter the server address in a web browser ( i.e. https://127.0.0.1:5000/
) before my angular app was able to access the flask socketio https server, but I think that is a client side issue I need to work out.
Old question but I'll give an answer anyway. Try something like this:
if __name__=='__main__':
socketio.run(app, host='0.0.0.0', port=80, debug=True, keyfile='key.pem', certfile='cert.pem')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With