One, HTTPS request flowchart
1, HTTPS before the actual request data, will first with the server a few handshake verification, to prove mutual identity, such as:
Second, the verification process
The preparation for HTTPS communication. The most important is the client pre-provisioning Certificate Authority root certificate , server-side generation certificate .
1, the Client
In the current mainstream browser, some of the root certificates issued by common institutions ( the public key of the certification authority) will be built-in
2. Service side
1, a server to apply for a certificate, you must first generate a pair of public private key;
2. The server will give the public key to the third party certificate authority to buy the certificate;
3, the certificate authority uses its own private key to sign the public key of the service side (that is, the public key of the certificate Authority + this signature, can verify the correctness of the public key of the server);
4, the issue of the certificate, is the actual return of the server's public key, coupled with the agency with a private key to do the signature;
5, server-side deployment of this certificate;
1. The client initiates an HTTPS request to send a series of cipher suite (key algorithm suite, abbreviated cipher) to the server.
2, the server receives the client all the cipher after the comparison with its own support, if not supported, the connection is broken, and vice versa will choose a cryptographic algorithm and hash algorithm in the form of a certificate returned to the client certificate also contains the public key
Certificate Authority website expiration date and so on (this is clear text.) The meaning of the plaintext is that this certificate is intercepted, tampering can be identified by the client).
3, the client receives the service side response will do the following several things:
3.1 Verifying the legality of a certificate
Whether the authority that issued the certificate is legal and whether it expires, and whether the website address contained in the certificate is consistent with the address being accessed.
According to the information of the issuing agency in the certificate, the certificate (public key) of the corresponding institution is taken out locally, and the public key signature of the server is verified . If the signature is verified correctly, the server's public key is guaranteed by this agency.
If the corresponding authority certificate is not found locally, or the signature is not authenticated correctly, the certificate fails.
After the certificate is validated, a small lock is added to the address bar of the browser (each browser will not be discussed after the validation pass).
3.2 Generating Random passwords
If the certificate is validated, or if the user accepts a certificate that is not trusted, the browser generates a string of random numbers and then encrypts it with the public key in the certificate.
3.3 Hash Handshake information
Use the first agreed hash method, the handshake message hash value, and then use random number Encryption "handshake message + handshake message hash value (signature)" and sent together to the server.
The reason to take the hash value of the handshake message here is to make a signature of the handshake message to verify that the handshake message has not been tampered with during transmission.
4, the server to get the client from the ciphertext, with their own private key to decrypt, to obtain a random number of passwords, and then use a random number password to decrypt the handshake message and hash value, and to pass the hash value to make a comparison to confirm whether it is consistent. And then with the confidential
The code encrypts a handshake message (the hash value of the handshake message + handshake message) to the client.
5, the client decrypts and calculates the hash of the handshake message with a random number, if it is consistent with the hash of the server, at which point the handshake process is complete, then all the communication data will be generated by the previous browser random password and the use of symmetric encryption algorithm
Encryption, because this string of keys is only known to the client and the server, so even if intermediate requests are intercepted, it is impossible to decrypt the data to ensure the security of the communication.
Algorithm
Asymmetric encryption algorithm: RSA,DSA/DSS symmetric encryption in the process of mutual authentication between the client and the server
Symmetric encryption algorithm: Aes,rc4,3des client and server mutual authentication pass, when the random number as the key, is symmetric encryption
Hash algorithm: md5,sha1,sha256 when confirming that the handshake message has not been tampered with
Reference from:
http://www.cnblogs.com/zery/p/5164795.html HTTPS principle Analysis
http://www.cnblogs.com/qqmomery/p/6107432.html HTTPS Basic Process
HTTPS Basic Process