DEV Community

Cover image for Easy understanding of web protocols - HTTP and HTTPS
Yogesh Kasliwal
Yogesh Kasliwal

Posted on • Updated on

Easy understanding of web protocols - HTTP and HTTPS

Introduction

Google announced that websites with SSL Certificate / HTTPS protocol will be preferred in search engine results. I will try to cover the fundamentals of HTTP and HTTPS protocols.
Before we dive deeper into understanding about HTTP and HTTPS protocol, let’s try to understand the meaning of the word protocol.

What is a protocol ?

A Protocol is a set of rules that we use for specific purposes. In the current scenario, when we are talking about protocols, it is about communication- the way we talk to each other. For instance, a newsreader speaks in English and because you understand English, you are able to understand. English is the protocol.

The moment the newsreader starts speaking in a language that you don't understand, the protocol beats its purpose. Thus, we need both the parties to agree to a set of rules for the communication to take place. The protocol, in this case, is for communication.

Now, talking about the web, in particular, multiple protocols are used to communicate. Primarily for end users, the most important and visible protocols are HTTP and HTTPS. Though there are many other protocols as well, HTTP and HTTPS protocols cater to most of the population.

What is HTTP ?

HTTP is Hypertext transfer protocol. Simply put - Rules to sending and receiving text-based messages. As we all know, computers work in a language of 1's and 0's i.e. Binary language. Therefore, potentially every set of 1's and 0's construct something, it could be a word.

Let's say I want to write 'a'. Now, if 0 stands for 'a', 1 stands for 'b', and 01 stands for 'c', I can infer that a combination of 0's and 1's can construct a word as well. In this case, the text is already constructed and is being sent on the wire. The computer works on many languages - pure binary, text and some other formats like byte codes. Here, what is being transferred is text. I am emphasizing on 'text' because this text is interpreted by the browser and the moment browser interprets it, it becomes hypertext, and the protocol that transfers the text is referred to as hypertext transfer protocol - HTTP.

Using HTTP, you can definitely transfer images and text and even sound, but not videos.

What is HTTPS ?

Hyper Text Transfer Protocol Secure (HTTPS) is the secure version of HTTP, the protocol over which data is sent between your browser and the website that you are connected to. The 'S' at the end of HTTPS stands for 'Secure'. It means all communications between your browser and the website are encrypted. HTTPS is often used to protect highly confidential online transactions like online banking and online shopping order forms.

What is the importance of HTTPS ?

We agreed upon the fact that what is being transferred from one point to another is text. To understand why HTTPS protocol, we first should know how wi-fi routers function. Let's say you are at an airport and you are connecting to the wi-fi which is the property of a third party. Now, when you are communicating over HTTP, the text is being transferred by their router. And if I go to a low version of the router, I can comfortably check and read the text that is being transferred. There could be a password that I can use to login to your bank site and do a fraudulent transaction!. Point being - this is fundamentally insecure. This is called the man in the middle attack.

And this why do we need https when HTTP seems to suffice.

Now, to save our data from such attacks, we need to encrypt that data.

Alt Text

In fact, in order to implement an advanced secure connection for users, in 2014 the search engine giant announced HTTPS as a ranking signal.

Encryption and Encryption Levels

Encryption is simple terms is a hiding information. There are various ways to do so. You must have heard these terms - 128 bit encrypt HTTPS and 64 bit encrypt HTTPS. 128-bit Encrypt is a high encryption technique and it's very difficult to decrypt (decode). In the case of HTTPS when the data is being transferred on the wires, the man in the middle may still know what is being transferred, but can not make sense out of it as the data is encrypted. Only the browser will decrypt it and show it, and the server will decrypt it and use it for transactions.

How does this happens when you request to open a site in a browser ?

To understand this, let us imagine that there is one Server that resides somewhere serving all the request for one domain. Now, when I type xyz.com, it's a server that I am connecting to, taking data from and rendering it in the browser.

To simplify further, imagine a domain name google.com being broadcasted from one server. There resides one machine somewhere connected to the internet and the moment you say google.com in your browser, you connect to that machine, pick data from that machine and show it in the browser. If you have saved your picture, it gets uploaded to that machine. Now, if you want to see that picture, you go to google.com/show-me-my-picture, which transfers the picture from the machine to the browser to be shown to you.

This process cannot be completed if I am not able to reach that particular machine. For this to happen, every machine has an address (the way we have a mobile number), it is called the IP address and every domain has an IP map. The moment you enter this user-friendly URL - google.com, it converts this username into IP and connects to the router to reach out to that particular service line associated with this URL. Once it reaches to the server, it raises a request of what is needed. It is represented as 'google.com/s=', helping the user understand the request made by him. As a result, the server gives him the results according to your request, which gets rendered to the browser.

What happens when a request for a website URL is made which is on HTTP protocol ?

As the first step, it is the job of HTTP to find out the server and once the communication route is established, the server sends a text to the browser. This text could either be in its pure form or encrypted form, which is then rendered by the browser or used for whatever purpose it has to it has to be used.

As there should be a measurement of this difficulty quotient, we interpret that, higher the number of bits, more difficult it is to decrypt. However, it only increases the level of complexity making it very difficult to decrypt, but not impossible.

Deciding between HTTP and HTTPS

Alt Text

Anything and everything is personal. If you are searching for “How to install SSL Certificate”, that search would be private to you, isn't it? Whether you are browsing or looking for a product, reading an article, you generally do not want others to know about it. As an end user, I would want to keep it as private. There are things I might not want to keep private and for those, I can use HTTP. However, for personal information, banks and transnational information, HTTPS has become a standard.

HTTPS sounds great. What else should you know about it ?

There is no denying to the fact that privacy has a cost to it. There are a couple of cons-

  1. HTTPS requests take more time to process.

  2. Because it needs more time to process, it needs more hardware - the server that you are utilizing. This also means additional cost

Whereas, for HTTP you use lesser energy as compared to HTTPS as the communication happens faster (without encryption and decryption). However, I will not refer to it as a limitation for HTTPS. It is highly subjective and personal, I consider it a very low cost that we pay to ensure our privacy.

The idea of building a secure web has been around for a while. Because of the following two reasons -

  1. User Data and User Privacy: Using HTTPS ensures that you as a developer care value user data, user’s privacy, and its security.

  2. Protecting Your Data: As a developer, we would never want to give away our critical data to malicious participants.

For more information- https://developer.mozilla.org/en-US/docs/Glossary/https

Top comments (0)