<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Manav Shandilya</title>
    <description>The latest articles on DEV Community by Manav Shandilya (@manav_shandilya_172f8a218).</description>
    <link>https://dev.to/manav_shandilya_172f8a218</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2575100%2Fdd2db36d-f448-4b42-981e-f76bd56f59bc.jpg</url>
      <title>DEV Community: Manav Shandilya</title>
      <link>https://dev.to/manav_shandilya_172f8a218</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/manav_shandilya_172f8a218"/>
    <language>en</language>
    <item>
      <title>Understanding the Importance of SSL Certificates and How They Work</title>
      <dc:creator>Manav Shandilya</dc:creator>
      <pubDate>Tue, 17 Dec 2024 15:59:02 +0000</pubDate>
      <link>https://dev.to/manav_shandilya_172f8a218/understanding-the-importance-of-ssl-certificates-and-how-they-work-438h</link>
      <guid>https://dev.to/manav_shandilya_172f8a218/understanding-the-importance-of-ssl-certificates-and-how-they-work-438h</guid>
      <description>&lt;p&gt;&lt;strong&gt;The Need for SSL Certificates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To grasp the significance of SSL certificates, let’s explore how asymmetric encryption works. In asymmetric encryption, two keys are involved: a public key and a private key. The public key is used to encrypt data, while the private key is used to decrypt it.&lt;/p&gt;

&lt;p&gt;When a server wants to establish a secure connection, it generates its public and private keys. The public key is shared openly with clients over the network, even in the presence of a potential Man-in-the-Middle (MITM) Attack, as the public key itself does not compromise security.&lt;/p&gt;

&lt;p&gt;Upon receiving the server's public key, the client generates its own symmetric key (used for faster encryption). The client then encrypts this symmetric key using the server's public key and sends it back to the server. Since only the server holds the corresponding private key, it can decrypt the symmetric key securely. At this stage, both the client and server possess the same symmetric key, enabling secure data transmission through symmetric encryption.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Security Flaw: MITM Attack Risk&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While this process seems secure, it is vulnerable to a sophisticated MITM attack. An attacker could intercept the communication, replacing the server's public key with a fraudulent one. The client, unaware of the interception, would encrypt its symmetric key using the attacker’s fake public key and send it back. The attacker could then decrypt the symmetric key using their corresponding private key, gaining access to sensitive data being transmitted.&lt;/p&gt;

&lt;p&gt;To counter this critical vulnerability, SSL Certificates were introduced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How SSL Certificates Work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;SSL Certificates are issued by trusted entities known as Certificate Authorities (CAs) such as Let's Encrypt, DigiCert, and others. Here’s how the issuance and verification process works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Certificate Issuance:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The server sends its public key to the CA. The CA uses its own public and private keys to create a digital certificate containing:&lt;/p&gt;

&lt;p&gt;The server’s public key.&lt;/p&gt;

&lt;p&gt;A digital signature generated using the CA’s private key.&lt;/p&gt;

&lt;p&gt;Domain-specific information to link the certificate to the server’s identity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Certificate Delivery:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The CA sends the signed certificate back to the server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client-Server Communication:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When the client initiates a connection, the server sends its SSL certificate along with its public key. The client inspects the certificate to verify the server’s authenticity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Certificate Verification:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The client identifies the CA that issued the certificate and requests the CA’s public key. Using the CA’s public key, the client verifies the certificate’s digital signature. If the signature is valid, the client can trust the server’s public key as genuine. After successful verification, the client proceeds with the asymmetric encryption steps, ensuring a secure connection resistant to MITM attacks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why SSL Matters&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;By securing data transmission with encryption, SSL certificates ensure:&lt;/p&gt;

&lt;p&gt;Data Integrity: Preventing data tampering during transfer.&lt;/p&gt;

&lt;p&gt;Authentication: Verifying the server's identity.&lt;/p&gt;

&lt;p&gt;Confidentiality: Keeping sensitive data protected from prying eyes.&lt;/p&gt;

&lt;p&gt;SSL certificates have become essential for ensuring a secure online experience, protecting user data, and fostering trust in today’s digital world.&lt;/p&gt;

&lt;p&gt;Happy Coding ! 😊&lt;/p&gt;

</description>
      <category>learnandbuildinpublic</category>
    </item>
    <item>
      <title>Understanding Socket Programming with Node.js and Socket.IO</title>
      <dc:creator>Manav Shandilya</dc:creator>
      <pubDate>Tue, 17 Dec 2024 12:02:41 +0000</pubDate>
      <link>https://dev.to/manav_shandilya_172f8a218/understanding-socket-programming-with-nodejs-and-socketio-1phd</link>
      <guid>https://dev.to/manav_shandilya_172f8a218/understanding-socket-programming-with-nodejs-and-socketio-1phd</guid>
      <description>&lt;p&gt;Socket programming enables real-time, bidirectional communication between a client and a server. In this blog, we'll explore the fundamentals of socket programming using Node.js and Socket.IO, while drawing examples from a Real-Time Tracker project.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Socket Programming?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Socket programming involves creating a connection between two nodes over a network, enabling continuous data exchange. It's essential for applications like chat apps, online games, and real-time trackers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Use Socket.IO?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Socket.IO is a library that simplifies WebSocket implementation, providing features like event-driven communication, auto-reconnection, and cross-browser compatibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Core Concepts of Socket Programming&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Establishing a Connection&lt;/p&gt;

&lt;p&gt;A connection is established when the client and server communicate using WebSocket. In our project, this is done through:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const io = socketio(server);

io.on("connection", (socket) =&amp;gt; {
    console.log("New user connected");
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Emitting and Listening to Events&lt;/p&gt;

&lt;p&gt;Data is sent and received using custom events:&lt;/p&gt;

&lt;p&gt;Client to Server: Sending user location.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;navigator.geolocation.watchPosition((position) =&amp;gt; {
    const { latitude, longitude } = position.coords;
    socket.emit("send-location", { latitude, longitude });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Server to Client: Broadcasting location updates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;io.on("connection", (socket) =&amp;gt; {
    socket.on("send-location", (data) =&amp;gt; {
        io.emit("receive-location", { id: socket.id, ...data });
    });
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Handling Disconnections&lt;/p&gt;

&lt;p&gt;Handling user disconnections ensures accurate tracking:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;socket.on("disconnect", () =&amp;gt; {
    io.emit("user-disconnected", socket.id);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rendering Data on the Client Side&lt;/p&gt;

&lt;p&gt;The client listens for updates and updates the UI accordingly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;socket.on("receive-location", (data) =&amp;gt; {
    const { id, latitude, longitude } = data;
    map.setView([latitude, longitude]);
    if (!markers[id]) {
        markers[id] = L.marker([latitude, longitude]).addTo(map);
    } else {
        markers[id].setLatLng([latitude, longitude]);
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Real-Time Updates and Map Integration&lt;/p&gt;

&lt;p&gt;By combining Leaflet.js with Socket.IO, we display real-time user positions on a map.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const map = L.map("map").setView([0, 0], 16);
L.tileLayer("https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png", {
    attribution: "OpenStreetMap",
}).addTo(map);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Socket programming enables real-time communication in web applications. Using Node.js and Socket.IO simplifies this process, as demonstrated through our Real-Time Tracker example. Understanding the core concepts will help you build scalable, interactive applications with ease.&lt;/p&gt;

&lt;p&gt;Happy coding! 🚀&lt;/p&gt;

</description>
      <category>learnandbuildinpublic</category>
    </item>
    <item>
      <title>Understanding JWT, Cryptography, and Authentication Best Practices</title>
      <dc:creator>Manav Shandilya</dc:creator>
      <pubDate>Mon, 16 Dec 2024 15:03:51 +0000</pubDate>
      <link>https://dev.to/manav_shandilya_172f8a218/understanding-jwt-cryptography-and-authentication-best-practices-ibh</link>
      <guid>https://dev.to/manav_shandilya_172f8a218/understanding-jwt-cryptography-and-authentication-best-practices-ibh</guid>
      <description>&lt;p&gt;Authentication and data security are at the core of modern web applications. In this post, we’ll explore important concepts like public &amp;amp; private key cryptography, stateless vs state full systems, JWT structure, secure storage practices, and token invalidation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Public &amp;amp; Private Key Cryptography&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Public and private key cryptography, also known as asymmetric encryption, secures data transmission using a pair of keys:&lt;/p&gt;

&lt;p&gt;Public Key: Shared openly and used to encrypt data.&lt;br&gt;
Private Key: Kept secret and used to decrypt data.&lt;/p&gt;

&lt;p&gt;How It Works: The sender encrypts the data with the recipient's public key. Only the recipient with the private key can decrypt the data. Used in SSL certificates, email encryption, digital signatures.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Stateless vs State full Systems&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Authentication systems can be either stateless or state full.&lt;/p&gt;

&lt;p&gt;Stateless Systems: No session storage on the server. Each request is self-contained, usually with tokens like JWT. Easier to scale horizontally.&lt;/p&gt;

&lt;p&gt;State full Systems: Requires server-side session storage. Relies on session IDs stored in cookies. More secure but less scalable without extra infrastructure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. What is JWT (JSON Web Token)?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. How is a JWT Structured?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A JWT has three parts:&lt;/p&gt;

&lt;p&gt;Header: Specifies the token type (JWT) and hashing algorithm.&lt;/p&gt;

&lt;p&gt;Payload: Contains claims (user data, roles, expiration). This is not encrypted.&lt;/p&gt;

&lt;p&gt;Signature: Verifies the token’s authenticity.&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0ctmrmhlw8ooo66jgvx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq0ctmrmhlw8ooo66jgvx.jpg" alt="Image description" width="800" height="467"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. How Can You Invalidate a JWT?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JWTs are stateless and cannot be invalidated server-side by default, but there are workarounds:&lt;br&gt;
Token Invalidation Strategies:&lt;br&gt;
Expiration Claims: Set a reasonable expiration time (exp claim).&lt;br&gt;
Revocation Lists: Maintain a blacklist of invalidated tokens.&lt;br&gt;
Token Rotation: Use refresh tokens with short-lived access tokens.&lt;br&gt;
Forced Logout: Change the secret key or revoke tokens after sensitive operations.&lt;/p&gt;

&lt;p&gt;Final Thoughts:&lt;br&gt;
Understanding cryptography, stateless systems, and JWT security practices is crucial for building secure backend systems. Let me know your thoughts, feedback, or additional insights in the comments!&lt;/p&gt;

&lt;p&gt;Resource: &lt;a href="https://jwt.io/" rel="noopener noreferrer"&gt;https://jwt.io/&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  LEARN&amp;amp;BUILDINPUBLIC | Happy Coding😊
&lt;/h1&gt;

</description>
      <category>learnandbuildinpublic</category>
    </item>
  </channel>
</rss>
