SSL-TLS Certificate Setup
SSL-TLS Certificate Setup
DevOps Shack
SSL/TLS Certificate Setup and Management
in DevOps: A Practical Guide
Table of Contents
1. Introduction
1.1 Overview of CI/CD in DevOps
1.2 Importance of SSL/TLS in Secure Deployments
1.3 Choosing the Right SSL/TLS Management Approach
2. Setting Up a CI/CD Pipeline
2.1 Selecting a CI/CD Platform (GitHub Actions, GitLab CI/CD, Azure DevOps,
etc.)
2.2 Defining CI/CD Stages (Build, Test, Deploy)
2.3 Automating Deployments with Infrastructure as Code (IaC)
3. Generating & Configuring SSL/TLS Certificates
3.1 Choosing Between Self-Signed, Let’s Encrypt, and CA-Issued Certificates
3.2 Setting Up an SSL Certificate with Let’s Encrypt (Certbot)
3.3 Automating Certificate Generation in CI/CD
4. Deploying SSL/TLS Certificates in a Web Application
4.1 Configuring SSL for Web Servers (NGINX, Apache, IIS)
4.2 Applying SSL/TLS in Cloud Services (AWS, Azure, Kubernetes)
4.3 Securing API Endpoints with HTTPS
5. Automating SSL/TLS Management
5.1 Using Let’s Encrypt for Auto-Renewal
5.2 Storing and Managing Certificates Securely (Azure Key Vault, AWS
Certificate Manager)
5.3 Integrating SSL Management in CI/CD Pipelines
6. Monitoring & Troubleshooting SSL/TLS Certificates
2
6.1 Setting Up Certificate Expiry Alerts
6.2 Using OpenSSL & SSL Labs for Debugging
6.3 Fixing Common SSL/TLS Issues in Deployments
7. Best Practices for SSL/TLS in DevOps
7.1 Enforcing TLS 1.2/1.3 and Strong Cipher Suites
7.2 Implementing HSTS, OCSP Stapling, and Certificate Pinning
7.3 Automating Security Audits in the CI/CD Pipeline
8. Conclusion
8.1 Summary of CI/CD & SSL/TLS Integration
8.2 Future Trends in SSL/TLS Automation
8.3 Final Recommendations
3
1. Introduction
1.1 Overview of SSL/TLS
SSL (Secure Sockets Layer) and its successor TLS (Transport Layer Security) are
cryptographic protocols designed to provide secure communication over the
internet. They encrypt data transmitted between clients (browsers,
applications) and servers, ensuring confidentiality, integrity, and
authentication. TLS 1.2 and TLS 1.3 are the widely used secure versions today.
1.2 Importance of SSL/TLS in DevOps
In modern DevOps workflows, SSL/TLS plays a critical role in securing web
applications, APIs, and cloud environments. The key benefits include:
Data Encryption – Prevents unauthorized access and man-in-the-middle
(MITM) attacks.
Authentication – Ensures that the client is communicating with the
intended server.
Data Integrity – Protects against tampering during transmission.
Regulatory Compliance – Helps meet security standards like GDPR, PCI-
DSS, and HIPAA.
SSL/TLS certificates are essential in DevOps pipelines to maintain secure
deployments, protect customer data, and build trust.
1.3 Choosing the Right SSL/TLS Management Approach
Managing SSL/TLS certificates in DevOps environments can be automated and
streamlined using various tools and services. The best approach depends on:
Scale of deployment – Small-scale apps vs. enterprise-level
infrastructure.
Cloud provider – AWS, Azure, Google Cloud offer managed certificate
services.
Automation level – Manual vs. fully automated certificate issuance and
renewal.
Common SSL/TLS management options:
1. Let’s Encrypt – Free, automated certificate issuance and renewal.
4
2. Cloud-managed solutions – AWS Certificate Manager (ACM), Azure Key
Vault, Google Cloud Certificates.
3. Self-signed certificates – For internal environments or testing.
4. Commercial Certificate Authorities (CAs) – Sectigo, DigiCert, GlobalSign,
for enterprise-grade security.
This document will guide you through the setup, deployment, automation,
and management of SSL/TLS certificates in DevOps environments, ensuring
secure and scalable application deployments.
5
2. SSL/TLS Basics
2.1 What is SSL/TLS?
SSL (Secure Sockets Layer) and TLS (Transport Layer Security) are cryptographic
protocols designed to encrypt communication over the internet. TLS has
replaced SSL due to its enhanced security features, and TLS 1.3 is the latest
version, offering improved performance and security.
How SSL/TLS Works:
1. Client Hello – The client (browser or application) initiates a handshake
with the server, listing supported cryptographic algorithms.
2. Server Hello – The server selects the strongest mutual encryption
method and sends its SSL/TLS certificate.
3. Certificate Validation – The client verifies the server’s certificate against
trusted Certificate Authorities (CAs).
4. Key Exchange – Both sides securely exchange cryptographic keys.
5. Secure Communication Begins – All transmitted data is now encrypted.
6
3. Extended Validation (EV)
o Highest level of validation.
o Displays a company name in the address bar (e.g., green bar in
some browsers).
o Recommended for financial institutions and government sites.
Based on Usage:
1. Single Domain Certificate – Protects one domain (e.g., example.com).
2. Wildcard Certificate – Secures a domain and its subdomains
(*.example.com).
3. Multi-Domain (SAN) Certificate – Protects multiple domains
(example.com, test.com).
7
Private Certificates: Used internally in enterprises, issued by private CA
(e.g., Active Directory Certificate Services).
8
3. Generating & Configuring SSL/TLS Certificates
In this section, we’ll cover the step-by-step process to generate, configure, and
install SSL/TLS certificates using different methods, including Let’s Encrypt,
OpenSSL, and cloud-managed services.
Free,
Expires every 90
automated,
Let’s Encrypt Public websites days, needs renewal
widely
automation
supported
Cloud CA (AWS
Cloud-native Fully managed, Limited to cloud
ACM, Azure Key
applications auto-renewal environments
Vault, GCP)
9
sudo apt install certbot
For NGINX or Apache, install the respective Certbot plugin:
sudo apt install python3-certbot-nginx # For NGINX
sudo apt install python3-certbot-apache # For Apache
Step 2: Generate the Certificate
For NGINX:
sudo certbot --nginx -d example.com -d www.example.com
For Apache:
sudo certbot --apache -d example.com
This command:
✅ Requests a certificate from Let’s Encrypt.
✅ Configures NGINX/Apache automatically.
✅ Sets up auto-renewal.
Step 3: Verify SSL Certificate
Run:
sudo certbot certificates
To renew manually:
sudo certbot renew --dry-run
3.3 Generating a Self-Signed SSL Certificate (For Internal Use & Testing)
Self-signed certificates are useful for development and internal applications.
Step 1: Generate a Private Key & CSR
openssl req -newkey rsa:2048 -nodes -keyout mykey.pem -out myrequest.csr
mykey.pem → Private key
myrequest.csr → Certificate Signing Request
Step 2: Create a Self-Signed Certificate
10
openssl x509 -req -days 365 -in myrequest.csr -signkey mykey.pem -out
mycertificate.pem
This generates mycertificate.pem, which can be installed on a web server.
Step 3: Configure NGINX/Apache to Use the Certificate
For NGINX, add to your config (/etc/nginx/sites-available/default):
server {
listen 443 ssl;
server_name example.com;
ssl_certificate /path/to/mycertificate.pem;
ssl_certificate_key /path/to/mykey.pem;
}
Then restart:
sudo systemctl restart nginx
For Apache, update ssl.conf:
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLCertificateFile /path/to/mycertificate.pem
SSLCertificateKeyFile /path/to/mykey.pem
</VirtualHost>
Restart Apache:
sudo systemctl restart apache2
11
Issue SSL certificates for free (but only works with AWS services like ELB,
CloudFront).
Automatically renews certificates.
To request a certificate via AWS CLI:
aws acm request-certificate --domain-name example.com --validation-method
DNS
Azure Key Vault for SSL Certificates
Stores SSL certificates securely.
Can be integrated with Azure App Services & Kubernetes.
To import a certificate to Azure Key Vault:
az keyvault certificate import --vault-name MyKeyVault --name MySSLCert --file
mycertificate.pfx
Google Cloud Managed Certificates
Works with Google Cloud Load Balancers.
Auto-renewal enabled.
Create a managed certificate:
apiVersion: networking.gke.io/v1beta1
kind: ManagedCertificate
metadata:
name: my-managed-cert
spec:
domains:
- example.com
12
systemctl list-timers | grep certbot
Or manually add a cron job:
crontab -e
Add this line:
0 3 * * * certbot renew --quiet
This renews certificates daily at 3 AM.
13
4. Deploying SSL/TLS Certificates in Web Applications
This section covers how to deploy SSL/TLS certificates on different platforms,
including web servers (NGINX, Apache, IIS), cloud services (AWS, Azure, GCP),
and containerized applications (Docker, Kubernetes).
ssl_certificate /etc/ssl/certs/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;
14
Step 3: Restart NGINX
sudo systemctl restart nginx
4.1.2 Deploying SSL on Apache
Step 1: Enable SSL Module
sudo a2enmod ssl
Step 2: Configure Virtual Host for SSL
Edit the Apache SSL configuration file (/etc/apache2/sites-available/default-
ssl.conf):
<VirtualHost *:443>
ServerName example.com
SSLEngine on
SSLCertificateFile /etc/ssl/certs/fullchain.pem
SSLCertificateKeyFile /etc/ssl/private/privkey.pem
SSLCipherSuite HIGH:!aNULL:!MD5
</VirtualHost>
Step 3: Restart Apache
sudo systemctl restart apache2
15
Choose the ACM Certificate and save.
AWS ACM automatically renews the certificate!
server {
listen 443 ssl;
server_name api.example.com;
ssl_certificate /etc/ssl/certs/fullchain.pem;
ssl_certificate_key /etc/ssl/private/privkey.pem;
location / {
proxy_pass http://backend_server;
proxy_set_header X-Forwarded-Proto https;
}
}
4.3.2 Securing Kubernetes API Endpoints
If your API runs inside Kubernetes, use Ingress with TLS:
17
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: api-ingress
annotations:
nginx.ingress.kubernetes.io/ssl-redirect: "true"
spec:
tls:
- hosts:
- api.example.com
secretName: tls-secret
rules:
- host: api.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: api-service
port:
number: 443
Ensure your certificate is stored in Kubernetes as a secret:
kubectl create secret tls tls-secret --cert=fullchain.pem --key=privkey.pem
18
To enforce HTTPS, configure redirects:
For NGINX:
server {
listen 80;
server_name example.com;
return 301 https://$host$request_uri;
}
For Apache:
Add this to .htaccess:
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
19
5. Automating SSL/TLS Management
Managing SSL/TLS certificates manually can be time-consuming, especially in
production environments where frequent renewals and deployments are
required. This section focuses on automating SSL/TLS certificate issuance,
renewal, and deployment using tools like Certbot, ACME clients, cloud
automation, and Kubernetes cert-manager.
20
sudo certbot renew --dry-run
If successful, it means renewal is working correctly.
ACME
Use Case Pros Cons
Client
21
Cloud providers offer fully managed SSL solutions with auto-renewal.
5.4.1 AWS Certificate Manager (ACM) Auto-Renewal
AWS ACM automatically renews certificates for ALB, CloudFront, and API
Gateway.
To verify auto-renewal status:
aws acm describe-certificate --certificate-arn arn:aws:acm:region:account-
id:certificate/certificate-id
5.4.2 Azure Key Vault SSL Automation
Azure can auto-renew certificates stored in Key Vault.
Enable auto-renewal using PowerShell:
Set-AzKeyVaultCertificateIssuer -VaultName "MyKeyVault" -Name "DigiCert" -
AutoRenew
22
acme:
server: https://acme-v02.api.letsencrypt.org/directory
email: [email protected]
privateKeySecretRef:
name: letsencrypt-prod
solvers:
- http01:
ingress:
class: nginx
Apply the configuration:
kubectl apply -f cluster-issuer.yaml
5.5.3 Issue SSL Certificates Automatically for Services
Modify your Kubernetes Ingress to request a TLS certificate:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-app-ingress
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
spec:
tls:
- hosts:
- myapp.example.com
secretName: myapp-tls
rules:
- host: myapp.example.com
23
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: my-app-service
port:
number: 80
This automatically provisions SSL certificates for myapp.example.com.
25
6. Best Practices for SSL/TLS Security
Setting up SSL/TLS certificates is just the first step. To ensure a robust security
posture, you need to follow best practices for encryption, certificate
management, and compliance. This section covers industry-recommended
SSL/TLS hardening strategies, secure cipher configurations, certificate lifecycle
management, and compliance requirements.
26
add_header Strict-Transport-Security "max-age=31536000;
includeSubDomains; preload" always;
In Apache:
Header always set Strict-Transport-Security "max-age=31536000;
includeSubDomains; preload"
⚠️ Caution: Ensure your site supports HTTPS fully before enabling HSTS to
prevent accessibility issues.
27
Avoid hardcoding private keys in application code or repositories.
6.4.2 Secure Cloud Storage for Certificates
AWS Key Management Service (KMS) for cloud-based encryption.
Azure Key Vault for managed certificate storage.
28
🔹 Requirement: Use TLS 1.2+ for secure transactions.
🔹 Verification: Test with
curl -v --tlsv1.0 https://example.com
If the connection succeeds, TLS 1.0 is enabled (which is insecure).
6.6.2 GDPR & Data Protection Compliance
29
7. Troubleshooting SSL/TLS Issues
Even with a properly configured SSL/TLS setup, issues can arise due to
misconfigurations, expired certificates, or compatibility problems. This section
covers common SSL/TLS errors, debugging techniques, and troubleshooting
steps to resolve them.
Certificate Renew
expired or certificate,
ERR_CERT_DATE_INVALID
system time check system
incorrect clock
Ensure CN
Incorrect
matches
NET::ERR_CERT_COMMON_NAME_INVALID domain name in
domain, reissue
certificate
cert
Renew
Expired or
certificate,
SEC_ERROR_EXPIRED_CERTIFICATE revoked
check CRL/OCSP
certificate
status
Cipher
Configure
mismatch,
proper cipher
SSL Handshake Failed missing
suites, include
intermediate
full chain
certs
30
Error Cause Solution
31
7.4.1 Checking SSL Logs in Nginx
If SSL fails in Nginx, check logs:
tail -f /var/log/nginx/error.log
Common issues:
❌ SSL: error:1408F10B:SSL routines:ssl3_get_record:wrong version number –
Fix by enabling TLS 1.2/1.3.
❌ ssl_stapling ignored, issuer certificate not found – Ensure correct OCSP
stapling configuration.
7.4.2 Apache SSL Debugging
To check Apache’s SSL configuration:
apachectl configtest
Restart Apache after fixing configuration issues:
systemctl restart apache2
32
7.7 Testing SSL/TLS Security Post-Configuration
7.7.1 Use SSL Labs Test
Scan your domain with:
👉 SSL Labs: https://www.ssllabs.com/ssltest/
Aim for A+ rating by fixing reported issues.
7.7.2 Scan for Weak Ciphers with Nmap
nmap --script ssl-enum-ciphers -p 443 example.com
If weak ciphers are found, update your web server’s SSL configuration.
33
8. Conclusion and Final Recommendations
Securing web applications with SSL/TLS certificates is essential for ensuring
encrypted communication, protecting user data, and maintaining trust. This
document has covered SSL/TLS certificate setup, renewal, automation,
troubleshooting, and best practices to help DevOps teams efficiently manage
certificates within their infrastructure.
✅ SSL/TLS Implementation
Obtained and installed SSL/TLS certificates from trusted Certificate
Authorities (CAs).
Configured certificates in Nginx, Apache, and cloud platforms.
Automated certificate renewal using Certbot, ACME clients, and cloud
providers.
✅ Security Enhancements
Enforced TLS 1.2/1.3, disabled weak protocols (SSLv3, TLS 1.0, TLS 1.1).
Implemented HSTS, OCSP stapling, and strong cipher suites.
Stored private keys securely and followed certificate lifecycle best
practices.
34
2⃣ Adopt Certificate Management Platforms
Consider AWS Certificate Manager (ACM), Let’s Encrypt with Certbot,
HashiCorp Vault for centralized SSL management.
3⃣ Regularly Audit & Test SSL Configuration
Run scheduled SSL vulnerability scans using security tools like SSL Labs,
Nmap, and Nessus.
4⃣ Train DevOps Teams on SSL Security Best Practices
Educate teams on certificate revocation, chain of trust, and encryption
hardening.
5⃣ Prepare for Post-Quantum Cryptography (PQC)
Stay updated on post-quantum cryptographic algorithms to future-proof
SSL/TLS security.
35
PCI DSS Security Standards: https://www.pcisecuritystandards.org/
GDPR Compliance Guide: https://gdpr.eu/
HIPAA Encryption Standards: https://www.hhs.gov/hipaa/
36