Last active
November 14, 2024 16:51
-
-
Save vpack/2d5f3f89affcc58dac462edbfdd5c119 to your computer and use it in GitHub Desktop.
Flask SSL Sample APP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask | |
from flask_sslify import SSLify | |
""" | |
Option 1 : (pip install pyopenssl) | |
from OpenSSL import SSL | |
context = SSL.Context(SSL.SSLv23_METHOD) | |
context.use_privatekey_file('web.key') | |
context.use_certificate_file('web.crt') | |
Option 2 : (OOB : No install) | |
import ssl | |
context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2) | |
context.load_cert_chain('web.crt', 'web.key') | |
Option 3 : Native Flask (No imports needed) | |
""" | |
app = Flask(__name__) | |
context = ('web.crt', 'web.key') | |
sslify = SSLify(app) | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
if __name__ == "__main__": | |
context = ('web.crt', 'web.key') | |
app.run( debug = True, ssl_context = context) | |
#app.run( debug = True, ssl_context = 'adhoc') # Generate Adhoc Certs |
Tengo el mismo problema, alguna solución?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm having the same problem @antoniojsp @omarnazih
Any answers?