GitLab SSL Certificate Renewal – Step-by-Step Guide

Overview

SSL certificate renewal for GitLab requires careful planning to avoid service disruption. This guide explains the end-to-end process for renewing GitLab SSL certificates across both Application and Database servers, including backup, CSR generation, certificate replacement, service restart, and verification.

This procedure ensures:

  • Secure HTTPS access
  • Zero data loss
  • Safe rollback using snapshots
  • Compliance with enterprise certificate standards

Environment Overview

Component

Description

GitLab Application Server

Hosts GitLab UI & services

GitLab Database Server

Hosts PostgreSQL

Access Method

CyberArk SSH

Certificate Type

Custom Root + Intermediate + Signed Certificate

 

High-Level Flow Diagram



Phase 1: Backup & CSR Preparation

Step 1: Take VM Snapshots

  • GitLab Application Server
  • GitLab Database Server

Ensures rollback safety in case of failure.

 Step 2: Login to GitLab Application Server

Access the server using CyberArk SSH.

 Step 3: Create CSR Directory (Application Server)

mkdir /root/certs/newcsr

cd /root/certs/newcsr

 Step 4: Generate CSR (Application Server)

openssl req -new -key gitlabappfqdn.key \

-config /root/certs/req.conf \

-out gitlabappfqdn.csr

Passphrase: XXXXXX

 Step 5–7: Repeat CSR Generation on Database Server

mkdir /root/certs/newcsr

cd /root/certs/newcsr

 

openssl req -new -key gitlabappfqdn.key \

-config /root/certs/req.conf \

-out gitlabappfqdn.csr

 

Phase 2: Remove Passphrase from Private Key

Step 8: Application Server

openssl rsa -in gitlabappfqdn.key -out gitlabappfqdn_nopasswd.key

mv gitlabappfqdn_nopasswd.key gitlabappfqdn.key

 Step 9: Database Server

openssl rsa -in gitlabappfqdn.key -out gitlabappfqdn_nopasswd.key

mv gitlabappfqdn_nopasswd.key gitlabappfqdn.key

 Step 10: Copy Signed Certificates

Copy the signed .crt and .key files to:

/root/certs/newcsr

(On both servers)

 Step 11: Verify Certificate Expiry

openssl x509 -in /root/certs/newcsr/gitlabappfqdn.crt -noout -dates

 Step 12: Copy DB Certificate to Application Server

scp gitlabappfqdn.crt app-server:/tmp/

 

Phase 3: Actual Certificate Renewal

Step 1–2: Pre-Checks

  • Snapshots confirmed
  • Root, Intermediate & Signed certificates available in:
  • /root/certs/newcsr

 Step 3: Archive Old CSR & Keys (Both Servers)

mv gitlabappfqdn.csr /root/certs/archive/2024/gitlabappfqdn.csr_old

mv gitlabappfqdn.key /root/certs/archive/2024/gitlabappfqdn.key_old

 Step 5: Archive Old Certificates

Application Server

mv /etc/gitlab/ssl/gitlabappfqdn.crt /root/certs/archive/2024/gitlabappfqdn.crt_old

Database Server

mv /var/opt/gitlab/postgresql/data/gitlabappfqdn.crt \

/root/certs/archive/2024/gitlabappfqdn.crt_old

 

Phase 4: Deploy New Certificates

Step 7: Application Server

cp /root/certs/newcsr/gitlabappfqdn.crt /etc/gitlab/ssl/

 Step 8: Database Server

cp /root/certs/newcsr/gitlabappfqdn.crt \

/var/opt/gitlab/postgresql/data/

 Step 9: Update Trusted Certificates

cp /etc/gitlab/ssl/gitlabappfqdn.crt /etc/gitlab/trusted-certs/

cp /tmp/gitlabappfqdn.crt /etc/gitlab/trusted-certs/

 

Phase 5: Reconfigure & Restart Services

Run on both servers:

gitlab-ctl reconfigure

gitlab-ctl restart

 Phase 6: Verification

 Application Validation

  • GitLab UI accessible
  • No service errors

 Certificate Validation

  1. Open GitLab URL (HTTPS)
  2. Click padlock
  3. View certificate details
  4. Confirm new expiry date

 

 Key Takeaways

Safe rollback using snapshots
Secure CSR handling
Proper certificate archival
Zero-downtime best practices
Enterprise-grade compliance

 

Conclusion

This structured GitLab certificate renewal process ensures security, stability, and audit readiness. Following this guide minimizes risk and guarantees smooth certificate rotation across both application and database layers.

Comments

Popular posts from this blog

Creating Snapshots for Unmanaged VMs in Aria Automation (vRealize Automation)

Bulk import security policies into Palo Alto Networks firewalls

Automating Tag Creation & Assignment to VMs with vRA + vRO