HTTPS that Thing (a)-https principle

Source: Internet
Author: User

https that Thing (a)

Recently read the "HTTP authoritative guide" several chapters, the HTTPS with the section, some information, then intend to record the experience. Write hastily, there must be a lot of mistakes in the place, welcome to correct them.


What is 1.HTTP?

Before you introduce HTTPS, it is necessary to explain the HTTP first. HTTP is a very easy and very complex protocol. It's easy to say that we use it every day. and unaware. It seems very easy to look. But you can really get to know the HTTP completely. It's not very easy. "HTTP authoritative guide" a thick book, all HTTP-related content, it can be seen how complex.

  • In simple terms. HTTP protocol is a Hypertext Transfer Protocol, which is a reliable transmission data protocol. The Web browser, like the one we use every day, is a httpclient, and the webserver that provides the content is the server side. The httpclient and server sides form the basic components of the World Wide Web. Webserver is the host of a Web resource. Web resources are the source of Web content, and the simplest web resource is static files in the webserver file system, such as text files and HTML files. Image. Word files and MP3. Avi and other audio-visual files, in addition to static files, Web resources may also be based on the need to produce content software programs. These can be seen as dynamic files.

  • A simple HTTP request is to open the browser from us. Enter the URL address to access the specified site start. A request command and a response result constitute an HTTP transaction.

    And almost all of the world's HTTP communication is hosted by the TCP/IP protocol, which is the familiar network ISO seven layer structure and the TCP/IP4 layer structure, in most cases we only discuss TCP/IP layered structure. So what is the detailed interview process? For example, we interview http://movie.douban.com/subject/10485647/?

    From=showing this link address. The following procedures are included in detail, for example:

    • 1. The browser resolves the initial host name. (host name is movie.douban.com)
    • 2. Browser query dnsserver the corresponding IP address of the host name. For example 211.147.4.32. Assuming that you have visited the site before, because DNS records are cached by the operating system, there is no need to parse again. Also, assuming that the webserver uses DNS rotation, the IP addresses that may be found are different at different times.
    • 3. The browser obtains the port number. The default here is 80.
    • 4. The browser initiates a connection to 211.147.4.32port80.
    • 5. The browser initiates a message for HTTP get to the server.
    • 6. The browser reads an HTTP response message from the server.
    • 7. The browser closes the connection.
  • A more specific process can participate in the HTTP authoritative guide. There is talk of concurrent connections, persistent connections, and connection pipelining to improve performance. In addition Here is an article about the process of an HTTP transaction, please see What happens when you load the page from the input URL .
2. From http to https

The primary HTTP is not secure enough in web transactions, which also spawned the birth of HTTPS. HTTPS is the password security layer that adds a layer of transport between HTTP and TCP-ssl or later is commonly used TLS.

The HTTPS protocol encrypts the data in the process of web communication, preventing data from being stolen. Overall, it's very safe. Even though OpenSSL recently burst out a Heartbleed loophole, it is now fixed.

The HTTPS prefix in the URL is HTTPS, and the default port is 443,http default port80.

2.1 Basic Process

Because of the SSL security layer, HTTPS establishes a secure transport process that is slightly more complex. HTTPclient (The browser is most often used) opens a connection to webserverport443.

Once a TCP connection is established, the client and server sides initialize the SSL layer, communicate the cryptographic parameters and exchange the keys. After the handshake is complete, SSL is initialized, and the client can send the request message to the security layer.

Of course, these messages are encrypted before they are sent to TCP.

2.2 SSL Handshake
  • The SSL handshake is the most complex step, with detailed steps such as the following:
  • 1.client (usually a Web browser) sends its own supported encryption rules to the server and requests a certificate.
  • 2.server selects a set of cryptographic algorithms and hash algorithms, and the server certificate is sent to the browser.

    (SSL supports two-way authentication.) Webserver sends the server certificate to the client. The client's certificate is then sent back to the server. However, many users in the actual application do not have their own client certificates. Therefore, server also rarely requires client certificates)

  • 3. The browser must verify the validity of the certificate after obtaining the server certificate. There are several steps in detail:Server certificates typically include information such as the certificate serial number, the certificate expiration time, the site organization name, the site DNS hostname, the public key of the Web site, and the certificate issuer name. The signature of the certificate issuer. Netscape proposes a webserver certificate validity algorithm that is the basis for most browsers to effectively validate server certificates.

    The main verification steps are as follows:

      • 3.1 date test.


        checks the certificate's start and end times to ensure that the certificate is still valid. If the certificate expires or has not been activated, the certificate validation fails and the browser prompts the error message.

      • 3.2 certificate issuer Confidence detection.


        Each certificate is issued by certain certification authorities (CAs) that are responsible for securing the server. The

        Certificate has different levels. Each type of certificate requires a different level of background validation. no one can generate a certificate, but some CAs are well-known organizations. They are able to verify the identity of the certificate applicant and the legitimacy of the business conduct through a clear process. Therefore, the browser typically comes with a trusted list of signature authorities. If the certificate is issued by an unknown institution, the browser displays a warning message.

      • 3.3 signature check. Once the certificate issuer is determined to be trustworthy. The browser needs to use the public key of the certificate issuer to sign the information and compare it to the signature in the certificate, assuming that the information may have been altered and cannot be verified.
      • 3.4 Web site authentication
        to prevent the server from replicating other people's certificates. Or intercept other people's traffic, most browsers try to verify that the DNS hostname included in the certificate matches the host name that is being conversation.

        If it does not match, either the browser warns the user. Or just terminate the connection directly. The handling of secure traffic on a virtual host (with multiple host names for a single server) is tricky. Some popular webserver programs only support a certificate, assuming that the user requests the virtual hostname, and the host name in the certificate does not match, so the browser will issue a warning.

        One way to do this is to redirect the virtual host domain name to the official hostname in the server certificate before you start the security transaction. (typically, only one host name is included in the server certificate.) However, some CAs create a certificate that includes a list of server names or a wildcard domain name for a group of servers

  • 4. Assume that server certificate validation is passed. The browser generates a bunch of random numbers as password (the random string generation that is actually used as a password is more complex, which simplifies its process.) The details can be added to HTTPS (ii)) and encrypted with the public key in the server certificate. In addition The browser uses the 2nd step to negotiate a good hash algorithm to encrypt the handshake message, the use of the password is just the string of random numbers generated.

    Finally, this information (the random number that is encrypted with the public key password, handshake message. Used hash algorithm, random number password encrypted handshake message signature) sent to the server.

  • 5.server receiving browser information, such as the following processing is required:
    • 5.1 Get the random number password with the private key decryption.

    • 5.2 A hash algorithm is used to sign the handshake message according to the random number password, which is more consistent than the signature issued by the browser and the signature of the calculation.

    • 5.3 Assume that signature verification passes. The random number password is used to encrypt a handshake message. Sent to the browser.
  • 6. The browser receives the handshake message and calculates the hash value of the handshake message using the random number password and the previous hash algorithm. The assumption is consistent with the hash value sent. at this point the handshake ends. Perhaps the message will be encrypted and decrypted by random number password. The encryption method used is symmetric encryption. Be aware of the non-symmetric encryption algorithm used by the previous public key cryptography and private key decryption.

algorithms used in 3.HTTPS

HTTPS generally uses cryptographic and hash algorithms such as the following:

Asymmetric Encryption algorithm: RSA,DSA/DSS

Symmetric encryption algorithm: AES,RC4. 3DES

Hash algorithm: md5,sha1,sha256

The asymmetric encryption algorithm is used when passing random number password.

The symmetric encryption algorithm is used after the secure connection is established. Used to speed up encryption and decryption. The hash algorithm is used to verify the data integrity of the SSL handshake process. The SSL handshake assumes that there are any errors that can cause the connection to break. This prevents the transmission of private information. Because HTTPS is very secure, attackers are very hard to find where to start, so many others use fake certificates to trick the client. The methods of identifying these fake certificates are described in section 2nd.


4. References
    • HTTPS those things one
    • HTTP Authoritative Guide 14 Chapter Security HTTP

Copyright notice: This article Bo Master original articles, blogs, without consent may not be reproduced.

HTTPS that Thing (a)-https principle

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.