1 need to install Python's OpenSSL class library, use Pip to install
1 pip install Pyopenssl
2 can be used directly in the code of Flask
from Import = Flask (__name__) app.run ('0.0.0.0', Debug=true, port=8100, ssl_context='adhoc')
The above code uses PYOPENSSL to bring your own certificate. If you want to use a certificate of your own configuration, you can configure it yourself and use it.
To generate a certificate:
Generate a private key
OpenSSL genrsa-des3-out Server.key 1024
Generate a CSR
OpenSSL Req-new-key server.key-out SERVER.CSR
Remove Passphrase from key
CP Server.key server.key.org OpenSSL RSA- in Server.key.org-out server.key
Generate Self signed certificate
OpenSSL x509-req-days 365- in Server.csr-signkey server.key-out server.crt
Using the configuration certificate, the certificate path is self-modifying
from Import Flask = Flask (__name__) app.run ('0.0.0.0', Debug=true, port=8100, Ssl_ context= ('/users/kracekumarramaraju/certificates/server.crt ' /users/kracekumarramaraju/certificates/server.key'))
Reference:
Http://kracekumar.com/post/54437887454/ssl-for-flask-local-development
http://flask.pocoo.org/snippets/111/
Http://blog.chinaunix.net/uid-9793706-id-3566191.html
Http://baike.baidu.com/view/5262561.htm
Python Flask using HTTPS security protocol