HTTPS handshake protocol and certificate authentication

Source: Internet
Author: User
Tags asymmetric encryption

1. What is https

Https = http + encryption + authentication

HTTPS is the security hardening of HTTP, and the encryption and authentication process is introduced on the basis of HTTP. Build a secure transport channel with encryption and authentication. So HTTPS can be seen as: in the secure channel, the data is symmetric encrypted after transmission. This way, even if hackers break the security channel, there is a layer of data encryption. The security of data communication is greatly ensured.

2. HTTPS Evolution of

We'll start with the insecure aspects of HTTP, with three scenarios to illustrate how HTTPS comes into being and its rationale

Round 1:

Normal communication:

" customer", " server": Hello

"Server ", "Customer ": Hello, I am the server

This is a normal communication between the client and the server. In the middle there is no security check, the client learned that the other side is the server, it is completely believed that the other side is the server they want. In this case, if the server receives an attack, someone forges the server and the client is not aware of it. Since this communication is known to be unsafe, so the introduction of RSA encryption, the following: With the RSA private key encryption, RSA public key decryption is the signature; public key encryption, the private key decryption is encryption. So there was a second round of communication

Round 2:

"Customer", "Server ": Hello

"Server ", "Customer ": Hello, I am the server

"Customer ", "Server" : Prove to me that you are the server

"Server ", "Customer ": Hello, I am server {***********} (the content is signed with the private key )

"Customer ", "Server" :{My account is aaa, password is 123, send me the information of my balance see }{***********} ( RSA encryption of content with private key )

" server", " customer": { your balance is $}{***********} ( the content is signed with the private key)

In the second round of communication, the server is signed with the RSA private key, and the client authenticates with the RSA public key to determine the server identity. Although RSA encryption is introduced, the identity of the server is uniquely confirmed, but since all subsequent information on the server is encrypted through the RSA private key, and the public key is publicly available, this can cause all the contents of the server to be public for everyone else. So this communication also has a security problem.

Round 3:

"Customer", "Server ": Hello

"Server ", "Customer ": Hello, I am the server

"Customer ", "Server" : Prove to me that you are the server

" server ", "Customer ": Hello, I am the server {***********} ( RSA encryption of content with private key )

" customer ", "Server" :{We follow the communication process, with symmetric encryption, here is the symmetric encryption algorithm and the key} {***********} ( RSA encryption of content with public key )

" server", " customer": {OK, Roger! }{***********} ( encrypted with both negotiated keys- symmetric encryption algorithm)

" customer ", "Server" :{My account is aaa, password is 123, send me the information of my balance to see } {***********} ( encrypted with both negotiated keys- symmetric encryption algorithm)

" server ", "Customer ":{Your balance is $100 }[key | Symmetric encryption Algorithm ] {***********} ( encrypted with both negotiated keys- symmetric encryption algorithm)

In the third round of communication consists of two parts, the first part is the use of asymmetric encryption algorithm for identity authentication. In the second part, the symmetric encryption algorithm is used to encrypt and decrypt the information communication. This is the basic process of HTTPS building a secure channel.

3. Certificates

in the first part of the third round of communication, although the use of asymmetric encryption algorithm for identity authentication can be very safe, but the problem is how to put the RSA public key to the client, if the traditional way: send with the network or the communication process to carry the public key, There will be cases where the public key is tampered with. In order to solve this problem, there is a digital certificate. Issued by a third party that is recognized by everyone and is credible.

Digital certificates typically include:

    • Issuing authority for certificates
    • Validity period of the certificate
    • Public
    • Certificate owner (Subject)
    • The algorithm used by the signature
    • Fingerprint and fingerprint algorithm

In this way, the server in the authentication phase does not need to send the public key to the client, but the server-side certificate to the client, the client to the server certificate, through the authentication certificate to complete the identity authentication. General Certificate Certification includes: The validity of the certificate, certificate chain validation. The certificate chain is validated by a root certificate that authenticates the certificate at the first level. The certification process for the certificate chain is as follows:

After successful certificate authentication , the public key inside the server certificate can be used to authenticate the server.

The first part is the use of asymmetric encryption algorithm for identity authentication. At the same time, digital certificate is introduced to secure the key.

4. D-H key exchange algorithm

in the third round of communication, the first part of the identity authentication is through the asymmetric encryption algorithm, can guarantee its security, but the second part, because the use of symmetric encryption algorithm, if the guarantee key is not intercepted is the focus of the entire communication security. The DH key exchange algorithm is used in HTTPS. Its security is dependent on the discrete logarithm of the difficulty of being guaranteed. The following is a brief introduction to the DH key exchange algorithm. Look at a few mathematical nouns before introduction

3.1 Generating meta

For a prime number Q, if the value a mod q, a^2 mod q, a^3 mod q,... a ^q-1 mod q are different integers, and in some arrangement form from 1 to q-1, then the integer A is a generating element of the prime Q, or the meta-root. For example, 5 is a generator of 23.

3.2 Discrete logarithm

For the generation of an integer B and a prime Q, a unique exponential I can be found, allowing:

b = a^i mod q (0 <= i <= q-1)

Then the exponent i is called the discrete logarithm of a-base modulus Q of B.

For a given a,i,q it is easy to calculate the B, but it is very difficult to calculate the I for b,a,q. This is the basis of the DH algorithm and many public key cryptography algorithms.

3.3 DH key exchange process

User A and User B share the prime number Q and its generated meta A, now A and B key exchange

User A: Generates random number Xa < Q, calculates ya = a^xa mod q, and sends ya to B

User B: Generates a random number Xb < Q, calculates yb= A^XB mod q, and sends YB to a

A Get Yb after: Calculate ka = (Yb) ^xa mod q

b After getting Ya, calculate KB = (Ya) ^XB mod q

The final result is: Ka = Kb

The proof process is omitted here, and the surrogate method can soon prove ka = Kb

And the k here is the key that both A and B negotiate.

5. Handshake Protocol

Through the above, we can know the whole process of HTTPS actually includes the following processes: Certificate authentication, identity authentication, key exchange, transfer data encryption and decryption, the following is a complete HTTPS handshake protocol process:

The above HTTPS evolution section references: http://www.cnblogs.com/JeffreySun/archive/2010/06/24/1627247.html

HTTPS handshake protocol and certificate authentication

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.