Skip to main content

Understanding PKI The Complete Process Explained

The Complete Public Key Infrastructure (PKI) Process: From Key Generation to Certificate Verification

Public Key Infrastructure (PKI) is the backbone of secure communication on the internet. It ensures that sensitive data exchanged between clients and servers remains private and authentic. This blog post will guide you through the entire PKI process, from generating keys to verifying certificates and ensuring they haven't been revoked.


1. Key Pair Generation

The first step in PKI is generating a public-private key pair using an asymmetric cryptographic algorithm, such as RSA or ECDSA:

  • The private key is securely stored on the server and never shared.

  • The public key is included in the certificate and shared with the Certificate Authority (CA) during the certificate request process.

This key pair enables encryption and decryption, which are essential for secure communication.


2. Creating a Certificate Signing Request (CSR)

The server creates a Certificate Signing Request (CSR) to request a certificate from a trusted CA. The CSR includes:

  • The public key.

  • The server’s identity details (e.g., domain name, organization, location).

The CSR is then submitted to the CA for validation.


3. CA Issues the Certificate

Once the CA receives the CSR, it performs the following steps:

a. Validation

The CA verifies the server's identity using various methods, such as domain ownership verification or organizational checks. This ensures that the entity requesting the certificate is legitimate.

b. Hashing and Signing

  1. The CA creates a hash of the certificate data (e.g., public key and identity information) using a secure hashing algorithm like SHA-256.

  2. The CA then encrypts this hash with its private key to create a digital signature.

  3. The CA packages the public key, server identity details, and the digital signature into the certificate.

The resulting certificate guarantees the authenticity of the server and the integrity of the data.


4. Installing the Certificate on the Server

After receiving the signed certificate, the server installs it along with the private key. The certificate is often accompanied by intermediate CA certificates to establish a chain of trust. These certificates are essential for ensuring compatibility with all client devices.


5. Client-Server Communication (TLS Handshake)

When a client (e.g., a browser) connects to the server, the server presents its certificate during the TLS handshake. The client then validates the certificate through the following steps:

a. Signature Verification

  1. The client extracts the digital signature from the server’s certificate.

  2. Using the CA’s public key (from the client’s trusted root store), the client decrypts the signature to retrieve the original hash.

  3. The client recomputes the hash of the certificate data and compares it with the decrypted hash.

    • If the hashes match, the certificate is authentic and untampered.

    • If they don’t match, the certificate is invalid.

b. Domain Validation

The client ensures that the certificate’s Common Name (CN) or Subject Alternative Name (SAN) matches the domain it’s trying to connect to.

c. Validity Period Check

The client verifies that the certificate is within its validity period. Expired certificates are deemed invalid.


6. Checking Certificate Revocation

To ensure that the certificate hasn’t been revoked, the client performs one of the following checks:

a. Certificate Revocation List (CRL)

  • The certificate contains a link to a CRL provided by the CA.

  • The client downloads the CRL and checks whether the certificate’s serial number is on the list.

b. Online Certificate Status Protocol (OCSP)

  • The certificate includes an OCSP endpoint (URL) provided by the CA.

  • The client sends a real-time query to the CA’s OCSP server to check the certificate’s revocation status.

c. OCSP Stapling

  • The server pre-fetches the OCSP response from the CA and includes it in the TLS handshake.

  • This method reduces latency and improves performance by eliminating the need for the client to query the CA directly.


7. Establishing Secure Communication

Once the certificate is verified, the client and server establish a secure channel:

  1. The client generates a session key for encryption.

  2. The client encrypts the session key using the server’s public key (from the certificate).

  3. The server decrypts the session key using its private key.

  4. Both parties use the session key for symmetric encryption to ensure fast and secure communication.


8. Summary of the Entire Process

Preparation

  1. Generate a public-private key pair.

  2. Create and submit a CSR to a CA.

CA’s Role

  1. Validate the server’s identity.

  2. Hash the CSR data, sign it with the CA’s private key, and issue the certificate.

Server Installs the Certificate

  1. Install the certificate and the private key on the server.

TLS Handshake (Client-Server Communication)

  1. Server sends its certificate to the client.

  2. Client validates the certificate:

    • Signature verification.

    • Domain name match.

    • Check revocation (via CRL or OCSP).

Establish Secure Communication

  1. Client and server establish a secure connection using symmetric encryption.


Comments

Popular posts from this blog

How to import Putty Saved Connections to mRemoteNG

Just started using mRemoteNG and its being very cool to connect to different remote connection with different protocols e.g Window Remote Desktop, VNC to Linux, SSH, HTTP connection etc. from a single application. As new user I configured some remote desktop connection which was quite easy to figure out. But when I wanted to add SSH connections, it came in my mind to import all of the saved connections in the putty. But I couldn't figure it out how can it be done, though it was quite easy and here are the steps. Open your mRemoteNG Create a folder if you want segregation of multiple networks Create a new connection Enter the IP address of remote server under connection in Config pane Under the config pane, select protocol " SSH version 2 ".  Once you select protocol to SSH version 2 you are given option to import putty sessions, as shown in the snap below. In the above snap, I have imported CSR-AWS session from my saved sessions in Putty.

BGP Soft Reconfiguration vs. Route Refresh: Key Differences and Best Practices

In BGP (Border Gateway Protocol), managing route updates and reapplying new policies can sometimes be challenging, especially if you want to avoid resetting the BGP session. Two methods allow you to update routing policies without tearing down the session: BGP Soft Reconfiguration and BGP Route Refresh . While both methods serve the same purpose, they work differently and have distinct impacts on your router's resources. This post explains the key differences between Soft Reconfiguration and Route Refresh , when to use each, and why Route Refresh is preferred in most modern networks. 1. What is BGP Soft Reconfiguration? BGP Soft Reconfiguration is an older method of applying new policies (like route maps, filters, or prefix lists) without resetting the BGP session. It works by storing a local copy of all the routes received from a BGP neighbor before applying inbound policies. This local route copy allows the router to reprocess the routes when a policy change occurs. How So...

BGP Local Preference Controlling Outbound Traffic in BGP

In BGP, Local Preference is used to control the outbound traffic path. It helps you decide which egress point (exit point) should be used when you have multiple connections to external networks, such as ISPs. Local Preference is an attribute that is local to your AS and is shared with all iBGP peers but not with eBGP neighbors. Higher Local Preference = More preferred outbound path. Example Scenario : You have two external links: ISP1 (via CE1) and ISP2 (via CE2). You want traffic to prefer ISP1 for all outbound traffic. Network Topology : CE1 (connected to ISP1): 10.0.1.1/30 CE2 (connected to ISP2): 10.0.2.1/30 iBGP Router (Internal) connected to both CE1 (10.0.1.2/30) and CE2 (10.0.2.2/30). Configuration on CE1 (Higher Local Preference) : Create a route map to set the local preference to 200 for routes learned from CE1: route-map SET_LOCAL_PREF permit 10 set local-preference 200 In the BGP configuration for CE1, apply this route map to the neighbor: router bgp 65001 ne...