Python Flask using HTTPS security protocol

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.