Talk about what I know about HTTPS

Source: Internet
Author: User

First, the HTTP protocol

First of all, I'm not going to go into this stuff very deeply, even though I've spent a lot of time studying it. Mostly I think about it.
1, oneself does not have the system to study this piece of knowledge, the explanation will compare superficial.
2, even if you understand this thing is not necessarily for you crossing to speak clearly this thing.
Considering the above two, I decided on the HTTP this one, I will focus on:
1, the basic concept of HTTP
2, three handshake of HTTP
3, four waves of HTTP
4. Common HTTP Methods
5. Common HTTP status Code

1, the basic concept of http:

协议Refers to the communication between two computers in a computer communication network 必须 , and the Hypertext 规定或规则 Transfer Protocol (HTTP) is a communication protocol that allows Hypertext Markup Language (HTML) documents to be transferred from the Web server to the client's browser.

http协议, which is the Hypertext Transfer Protocol. is a detailed regulation of the browser and the World Wide Web server communication between the rules, through the Internet to transmit the World Wide Web document data Transfer Protocol.

The HTTP protocol is a transfer protocol used to transfer hypertext from a World Wide Web server to a local browser. It can make the browser more efficient and reduce the network transmission. It not only ensures that the computer transmits hypertext documents correctly and quickly, but also determines which part of the document is being transmitted, and which content is displayed first (such as text before graphics), and so on.

HTTP is a 应用层协议 standard client server model that consists of requests and responses.

HTTP protocol 永远都是客户端发起请求,服务器回送响应 . This limits the use of the HTTP protocol, which cannot be implemented when the client does not initiate a request, the server pushes the message to the client.

The main features of the HTTP protocol can be summarized as follows:
1, support client/server mode. Support Basic authentication and security certification.
2, simple and fast: When a customer requests a service from the server, it simply transmits the request method and path. The request method commonly has, post. Each method specifies a different type of contact between the customer and the server. Because the HTTP protocol is simple, the HTTP server's program size is small, so the communication speed is fast.
3, Flexible: HTTP allows the transfer of any type of data objects. The type being transmitted is marked by Content-type.
4, HTTP 0.9, and 1.0 use a non-persistent connection: Restricts each connection to only one request, the server finishes processing the customer's request, and receives the customer's response, which disconnects the connection. HTTP 1.1 uses persistent connections: You do not have to create a new connection for each Web object, and a connection can transfer multiple objects in such a way that you can save transfer time.
5, stateless: HTTP protocol is a stateless protocol. Stateless means that the protocol has no memory capacity for transactional processing. A lack of state means that if the previous information is required for subsequent processing, it must be re-routed, which may cause the amount of data to be transferred per connection to increase.

2, three handshake of TCP

Talking about an issue that HTTP must be talking about.--http's three-time handshake, three-time handshake actually, after you really understand the problem, this thing will be easy for you to think about. First of all, you have to understand what three waves are used for?
In the TCP/IP protocol, the TCP protocol provides a reliable connection service with a three-time handshake to establish a connection. As shown

First understand the above meaning, you have to understand the meaning of several states: SYN (synchronous set up online) ACK (acknowledgement acknowledgment) PSH (push transfer) FIN (finish end) RST (reset reset) URG ( Urgent emergency).
In combination we divide the connection process into three processes:
(1): First, the client sends the SYN packet (SYN=J) to the server, and enters the Syn_send state, waits for the server to confirm;
(2): The server receives the SYN packet, must confirm the customer's SYN (ACK=J+1), simultaneously also sends a SYN packet (syn=k), namely the Syn+ack packet, at this time the server enters the SYN_RECV state;
(3): The client receives the server's Syn+ack packet, sends the acknowledgment packet ack (ACK=K+1) to the server, the packet is sent, the client and the server enter the established state, and the handshake is completed three times. Three handshake is completed and the client and server begin to transfer data.

3, four waves of TCP

Because TCP connections are full-duplex, each direction must be closed separately. The principle is that when a party completes its data sending task, it can send a fin to terminate the connection in this direction. Receiving a fin only means there is no data flow in this direction, and a TCP connection can still send data after receiving a fin. The first party to close will perform an active shutdown, while the other side performs a passive shutdown. As shown

Together, we divide the process of closing the connection into four processes:
(1) The client sends a FIN, which is used to turn off the client-to-server data transfer.
(2) The server receives this fin, it sends back an ACK, confirms that the serial number is the received sequence number plus 1. As with Syn, a fin will occupy a sequence number.
(3) The server closes the connection to the client and sends a fin to the client.
(4) The client sends back ACK message confirmation and sets the confirmation sequence number to receive the serial number plus 1.

4. Common HTTP methods and usage scenarios

There are many methods of HTTP, probably:
1. GET: Used to request access to a resource that has been identified by a URL (Uniform Resource Identifier) that can be passed to the server via a URL.
2, Post: For transmitting information to the server, the main function is similar to the Get method, but generally recommended POST mode.
3, PUT: Transfer files, message body contains the contents of the file, save to the corresponding URL location.
4, HEAD: Get the message header, similar to the Get method, just do not return the text body, generally used to verify that the URL is valid.
5. Delet: Delete the file, in contrast to the Put method, delete the file corresponding to the URL location.
6. OPTIONS: Query the HTTP method supported by the corresponding URL.
But I often use the Get plus post, I am here to briefly introduce the difference between the Get/post:
(1) Get requests are generally used to obtain data, and post requests are typically used to send data. It is expected that a GET request will not have any impact on the server, while a POST request may affect server-side data. Get requests consume fewer resources than post requests, but are relatively less secure. To send data of the same size, get requests can be up to twice times more efficient than the POST request.

(2) Generally as agreed, when using a GET request, the data is passed through the URL, but instead, the data is placed in the body with the POST request. But this is not a hard rule, because method and data are orthogonal in nature. The POST request can also place the data in the URL.

(3) In the case of the Protocol's underlying implementation, in a GET request, only a TCP packet is generated, the browser will send the header and data together, waiting for the response of the server, and in the POST request, will produce 2 TCP packets. , the browser sends the header first, the server responds to the continue, and the browser sends data.

5. Common HTTP status Code
Status Code response category reason phrase
1xx Informational Status code (informational) server processing request
2XX Success Status Code (Success) The request has been processed gracefully
3XX redirect Status code (redirection) requires additional action to complete the request
4XX Client Error status code client cause the server cannot process the request
5XX Server error State code (server error) server cause error processing request

Overall, I now have the project to be useful:
OK, the request is processed properly.
204 No Content request successfully processed, no entity body returned
304 not Modified sent with conditional request not satisfied
Bad Request message syntax error or parameter error
401 Unauthorized requires HTTP authentication, or authentication fails
403 Forbidden Request Resource denied
404 Not Found Cannot find request resource (server no reason to deny)
Internal Server error server failure or Web application failure
503 Service Unavailable server overload or shutdown maintenance

Ii. Overview of HTTPS

What about HTTPS? Can be understood as HTTP+SSL/TLS, that is, HTTP under the SSL layer, HTTPS security is based on SSL, so the details of the encryption requires SSL for secure HTTP data transfer. As we all know, when we use the HTTP protocol, the exchange of data is clear text, so it will bring a great deal of information security and then introduced HTTPS.
What am I doing here? This is primarily about HTTPS symmetric and asymmetric encryption. I'll focus on some of the cryptographic algorithms I'm working on when I actually start writing the algorithm chapters.

1. Symmetric encryption

What about symmetric encryption? To play an exact analogy, Xiao Ming and Xiao Hong in school when the alternate sentiment, but also afraid to be found by parents. So they came up with a way to put a box under a big tree and lock it up. If Xiao Red wrote a letter to Xiao Ming, inform Xiao Ming to take the key to go to put in the box inside the letter. So is Xiao Ming's trust.
The key of Xiao Ming and Xiao Hong is like the public key of the data transmission in symmetric encryption, and the data can be decrypted by the public key, which they only know by the public key. This encryption method to a certain extent above to achieve the effect of encryption. The advantage of this is that the symmetric encryption algorithm has the advantage 算法公开、计算量小、加密速度快、加密效率高 . But if Xiao Ming and red Key lost is the secret of both sides of the public key is lost, or Xiao Ming, red key is leaking is the public key decryption method is leaked so also can not achieve the effect of encryption.
I have an inappropriate animation here.

Background: Xiao Ming and Xiao Hong bought a box, a lock. Two people with two keys to the lock, want to pass this to convey the letter.
A headings Xiao Ming: Xiao Hong, I wrote a letter to you. (Symmetric encryption)
Two headings small red take out the key of the box, open the box to read Xiao Ming's letter. (Symmetric decryption)
Three headings Little red: Xiao Ming, I wrote back to you, (symmetric encryption)
Four headings Xiao Ming took out the key of the box, opened the box to read the letter of the small red back mail. (Symmetric decryption)

2. Asymmetric encryption

Since there is a large degree of flaw in symmetric encryption methods. So the clever computer fathers invented asymmetric encryption. What about asymmetric encryption? The way it works:
First, party B generates a pair of keys (public and private) and exposes the public key to other parties. Then the party that obtains the public key uses the key to encrypt the secret information and sends it to party B. In the end, party B decrypts the encrypted information with another private key (private key) that it saves. Party B can only use its private key (private key) to decrypt the information encrypted by the corresponding public key. The reverse is the same.
In doing so, even if the attacker intercepts the transmitted ciphertext during transmission and obtains the public key of B, the ciphertext cannot be cracked because only the private key of B can decrypt the text. This way to a certain extent 加强了数据的安全性 . But again 非对称加密的缺点是加密和解密花费时间长、速度慢,只适合对少量数据进行加密 .
I also drew an animation here.

Background: The young men and women who were master of the keys by their mothers, both bought an unlocked box
A headings small red with unlocked box and said to Xiao Ming: xiaoming, if you want to write with me, put in this box.
Two headings Xiao Ming will write a good letter, put in the box, and lock, and with Little Red said: "Little Red, I wrote to you."
Three headings Little Red took out the box key, the box inside the letter out, happy read up and feeling: Xiao Ming really interesting.

Four, finally say the point of HTTPS and HTTP

1. Basic concept:

HTTP: Is the most widely used Internet protocol, is a client and server-side request and response Standard (TCP), used to transfer hypertext to the local browser from the World Wide Web Server transmission protocol, it can make the browser more efficient, reduce network transmission.

HTTPS: is a security-targeted HTTP channel, simply speaking is the security version of HTTP, that is, HTTP under the SSL layer, HTTPS security base is SSL, so the details of encryption requires SSL. The main role of HTTPS protocol can be divided into two kinds: one is to establish an information security channel to ensure the security of data transmission, the other is to confirm the authenticity of the website.

2. What is the difference between HTTP and HTTPS?

1, the HTTPS protocol requires a certificate to the CA, generally less free certificate, and therefore a certain cost.
2, HTTP is a Hypertext Transfer Protocol, the information is plaintext transmission, HTTPS is a secure SSL encryption Transfer protocol.
3, HTTP and HTTPS use a completely different way of connection, with the same port, the former is 80, the latter is 443.
4, the HTTP connection is very simple, is stateless; The HTTPS protocol is a network protocol built by the SSL+HTTP protocol for encrypted transmission and authentication, which is more secure than the HTTP protocol.



Talk about what I know about HTTPS

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.