How do I translate the HTTP address of the server into HTTPS address

Introduction: recently in the micro channel small program, and then need to translate HTTP address into HTTPS address. This is my first article on getting started

1. Differences between HTTP and HTTPS

  • HTTP: HyperText Transfer Protocol (HTTP) is the most widely used network Protocol on the Internet. HTTP was originally designed to provide a way to publish and receive HTML pages. It makes the browser more efficient. The HTTP protocol sends information in plain text. If a hacker intercepts a packet transmitted between a Web browser and a server, he can obtain the information directly.
  • An HTTP connection is a connection to the server over the network. This connection is a TCP connection, and the default port is 80
  • HTTPS: The secure version of HTTP. The security basis of HTTPS is SSL. The SSL protocol is located between TCP/IP and various application-layer protocols and provides security support for data communication. The SSL Protocol consists of the following two layers: SSL Record Protocol. Based on reliable transport protocols such as TCP, SSL Record Protocol supports basic functions such as data encapsulation, compression, and encryption for high-level protocols. SSL Handshake Protocol, based on the SSL Recording Protocol, is used for identity authentication, encryption algorithm negotiation, and encryption key exchange between communication parties before data transmission.

Apply for an SSL certificate

Since the SSL certificate is mentioned, the next step is to apply for SSL certificate. This article takes Ali Cloud server as an example

  • Apply for an Aliyun CA certificate

Enter ali Cloud platform, findSSL Certificate Page, click on theCertificate of freeAnd click Buy Now to select in the selection screenDV single domain name certificateAnd click to buy (you can see the price is 0).

I’m going to go back and clickCreate a certificateAnd click theThe certificate application.

You can see the certificate binding domain name and is required, it seems that you need to apply for a domain name.

3. Domain name application

About domain name application, you can go to Ali cloud or Tencent cloud and other platforms to register a domain name. Domain name application after the completion of the website backup, ali cloud site backup for a long time…. I remember it took me nearly half a month to back up the website.

After applying for the domain name, you can do the previous operation. Fill in the domain name, click Next and click Verify.

Details of the final completed certificate are as follows

Download the certificate and deploy it to the server.

For example, in the Python Flask framework:

from flask import Flask, flash, get_flashed_messages

app = Flask(__name__,static_url_path='/')


if __name__ == '__main__':

    app.run(host='0.0.0.0',port=443,ssl_context=('domain. Pem'.'domain. The key'))
Copy the code