Sajiron
Network security plays a vital role in today’s digital landscape. Whether you’re browsing the web, handling online transactions, or building applications, secure communication is essential. This guide breaks down key concepts of network security, starting from the basics and moving towards advanced topics like encryption and the TLS handshake.
Before diving into security, let’s first understand how network communication works. When you visit a website or access an online service, your device (client) communicates with a server over the internet. This exchange follows a structured protocol to ensure smooth data transfer.
A client is any device or software that requests data or services from a server. Think of a client as someone sending a request to a store for a product or information. The store (server) then processes the request and responds with what was asked for.
Examples:
A browser accessing google.com
.
A mobile banking app retrieving account details.
A weather app pulling real-time updates from a cloud server.
A server is a system that responds to client requests. Imagine it as the store that provides the requested product or information to customers.
Examples:
Web servers (e.g., Apache, Nginx) hosting websites.
API servers handling requests from mobile and web applications.
File servers storing and managing shared documents.
The Internet Protocol (IP) is responsible for addressing, delivering, and routing online requests between devices. Just like how a mailing address helps send letters, an IP address uniquely identifies devices on the internet, ensuring that information is sent to the right place.
If you want to send a letter that requires a reply, you need to include the recipient’s address on the front of the envelope and your return address on the back. Similarly, when your device sends a request to a web server, it includes its own IP address so the server knows where to send the response.
Types of IP Addresses:
IPv4 (e.g., 192.168.1.1
): The older format, limited in number.
IPv6 (e.g., 2001:db8::ff00:42:8329
): The newer, more scalable format.
Without IP addresses, connected devices wouldn’t know where to send or receive data.
The Transmission Control Protocol (TCP) is one of the main protocols used for communication on the internet. Think of TCP as the process that ensures data is delivered accurately and in the right order, much like a phone conversation where both parties must hear each other's messages in the correct sequence.
Establishing a Connection: Before data transfer begins, TCP establishes a connection between the client and server using a process called the three-way handshake.
The client sends a SYN (synchronize) request to the server.
The server responds with a SYN-ACK (synchronize-acknowledge) message.
The client replies with an ACK (acknowledge), completing the connection setup.
Reliable Data Transfer:
TCP breaks data into smaller packets and ensures they arrive in the correct order.
If any packets are lost, TCP automatically requests retransmission.
Closing the Connection:
Once communication is complete, TCP ensures a proper disconnection so no data is lost.
Reliable communication – ensures all data is received and reassembled correctly.
Error detection – identifies lost or corrupted packets and requests retransmission.
Ordered delivery – ensures packets arrive in sequence, preventing mix-ups.
While TCP is widely used, some applications like video streaming or gaming use UDP (User Datagram Protocol), which is faster but does not guarantee delivery.
HTTP (HyperText Transfer Protocol) is the foundation of communication on the web. It enables clients to request resources from servers. Think of it as a standardized way to ask for and receive information online.
TCP is responsible for reliable data transmission, but it operates at a lower level in the networking model. It only knows how to break data into packets, send them, confirm receipt, and ensure correct ordering. It does not provide a structure for how web pages, images, or API requests should be formatted, interpreted, or processed.
HTTP sits on top of TCP and defines:
The format of requests and responses (e.g., GET
, POST
, PUT
, DELETE
)
The structure of data exchanged between clients and servers
Headers for metadata (e.g., content type, authentication, caching)
Status codes to indicate success or failure
A web browser (client) initiates an HTTP request by opening a TCP connection with a web server.
TCP ensures that the connection is reliable, confirming that all packets arrive and in the right order.
The HTTP request (formatted text defining the resource being requested) is sent over this TCP connection.
The web server processes the request and sends back an HTTP response.
Once the data transfer is complete, TCP ensures the connection is closed properly.
Without HTTP, TCP would just send raw data without any meaning, leaving it up to individual applications to figure out how to interpret the data. HTTP provides structure and makes web communication human-readable and standardized. However, HTTP is not secure because it transmits data in plaintext, making it vulnerable to interception by attackers.
Since HTTP does not encrypt data, attackers can perform man-in-the-middle (MITM) attacks, intercepting and modifying sensitive information like passwords or financial transactions. To address this, HTTPS (HTTP Secure) was introduced.
HTTPS is a secure version of HTTP that encrypts data using Transport Layer Security (TLS) to protect it from attackers. It ensures:
Confidentiality: Encrypts data so it cannot be read by unauthorized users.
Integrity: Prevents data from being altered during transmission.
Authentication: Confirms that the website you’re communicating with is genuine.
Websites using HTTPS display a padlock icon in the browser, indicating a secure connection.
Encryption is the process of converting data into an unreadable format to protect it from unauthorized access. There are two main types:
Uses the same key for encryption and decryption.
Faster but requires a secure way to share the key.
Example: AES (Advanced Encryption Standard), commonly used for secure data storage.
Uses a pair of keys: a public key (for encryption) and a private key (for decryption).
More secure than symmetric encryption but computationally slower.
Example: RSA (Rivest-Shamir-Adleman) encryption, used in SSL/TLS certificates.
TLS (Transport Layer Security) is a cryptographic protocol that ensures encrypted communication over a network. It is the backbone of HTTPS and replaces the older SSL (Secure Sockets Layer) protocol.
When you connect to an HTTPS website, the client and server go through a TLS handshake to establish a secure connection.
Client Hello:
The client sends a request to the server, including a list of supported encryption algorithms and a randomly generated string.
Server Hello:
The server responds with another randomly generated string and its SSL certificate, which contains its public key.
Certificate Validation:
The client verifies the server’s SSL certificate using a Certificate Authority (CA) to ensure it’s legitimate.
Premaster Secret Generation:
The client generates a premaster secret, encrypts it with the server’s public key, and sends it to the server.
The server decrypts this secret using its private key.
Session Key Generation:
Both client and server use the premaster secret to generate the same symmetric key for encrypting the session.
Secure Communication Begins:
From this point, all data exchanged is encrypted using symmetric encryption.
When you visit an HTTPS website, your browser needs to ensure that the server is legitimate. This is done by verifying its SSL certificate (a digital credential issued by a trusted authority).
Receiving the Certificate: The server presents its SSL certificate during the TLS handshake.
Checking the Certificate Authority (CA): The browser verifies that the certificate was issued by a trusted Certificate Authority (CA).
Validating the Certificate Chain: Many SSL certificates are issued through intermediate certificates, which must ultimately link back to a root certificate trusted by the browser.
Checking Expiry Date: SSL certificates have expiration dates. If expired, the browser displays a warning.
Verifying the Domain Name: The certificate must match the domain name. If not, the browser warns of a potential security issue.
Ensuring Certificate Revocation Status: The browser checks if the certificate has been revoked using methods like Certificate Revocation Lists (CRLs) or the Online Certificate Status Protocol (OCSP).
Completing the TLS Handshake: If all checks pass, encrypted communication begins.
If the certificate is self-signed or from an untrusted CA, the browser warns users.
If the certificate is expired, users see a certificate expiration error.
If the certificate’s domain doesn’t match, users receive a domain mismatch warning.
Domain Validation (DV): Verifies domain ownership (used for blogs and small websites).
Organization Validation (OV): Verifies business legitimacy (used by companies).
Extended Validation (EV): Provides the highest level of security (used by banks and financial institutions).
Understanding network security is essential in today’s digital world. Secure communication ensures that sensitive data remains safe from cyber threats. By using HTTPS, TLS, and SSL certificates, websites can build trust and protect their users.