HTTPS implementation principle
HTTPS (full name: Hypertext Transfer Protocol over secure Socket Layer) is a security-targeted HTTP channel and is simply a secure version of HTTP. That is, the SSL layer is added under HTTP, and the security base of HTTPS is SSL. The port number it uses is 443.
SSL: Secure Sockets Layer is a secure transport protocol designed primarily for the web by the Netscape company. This kind of protocol has been widely used on the web. Certificate authentication ensures that the communication data between the client and the Web server is encrypted and secure.
There are two basic types of encryption and decryption algorithms:
1) symmetric encryption (SYMMETRCIC encryption): The key is only one, encryption and decryption for the same password, and the decryption speed is fast, the typical symmetric encryption algorithm has DES, aes,rc5,3des and so on;
The main problem with symmetric cryptography is that the shared secret key, except that your computer (the client) knows the private key of another computer (the server), cannot encrypt and decrypt the communication stream. The solution to this problem is an asymmetric secret key.
2) Asymmetric encryption: Use two keys: Public key and private secret key. The private key is saved by a one-party password (typically the server is saved), and the public key is available to anyone on the other side.
This key in pairs appear (and according to the public key can not infer the private key, according to the private key can not infer the public key), encryption and decryption using a different key (public key encryption requires private key decryption, private key encryption requires public key decryption), relatively symmetric encryption speed is slow, the typical asymmetric encryption algorithm has RSA, DSA and so on.
Let's take a look at the HTTPS communication process:
The process is generally as follows:
1) After the SSL client establishes a connection over TCP and the server (443 port), the certificate is requested during a general TCP connection negotiation (handshake).
That is, the client sends a message to the server, which contains its own list of achievable algorithms and other required messages, the server side of SSL responds to a packet, which determines the algorithm required for this communication, and then the server returns the certificate to the client. (The certificate contains the server information: domain name.) The company that applied for the certificate, the public key).
2) After receiving the certificate returned by the server, the client determines the public issuing authority that issued the certificate, and uses the public key of the institution to confirm that the signature is valid, and also ensures that the domain name listed in the certificate is the domain name it is connecting to.
3) If you confirm that the certificate is valid, generate a symmetric key and use the server's public key to encrypt it. It is then sent to the server, which decrypts it with its private key so that both computers can begin to communicate with symmetric encryption.
Advantages of HTTPS communication:
1) The client-generated key can be obtained only by the client and the server;
2) encrypted data can only be plaintext by client and server;
3) client-to-server communication is secure.
HTTPS implementation principle