Runbook: Obnova certifikata

Trajanje: ~10 minut
Vloga: Varnostni administrator
Pogostost: Vsakih 90 dni (Let's Encrypt) ali letno

Obnova TLS-certifikata za Data Gateway.


Potek dela

flowchart TD A[Opozorilo o poteku] --> B{Vrsta certifikata?} B -->|Let's Encrypt| C[certbot renew] B -->|Interna CA| D[Zahtevaj nov certifikat] B -->|Komercialni| E[Obnovi pri ponudniku] C --> F[Zamenjaj certifikat] D --> F E --> F F --> G[Ponovno zaženi Gateway] G --> H[Testiraj HTTPS] H --> I{V redu?} I -->|Da| J[Končano] I -->|Ne| K[Obnovi stari certifikat] style J fill:#e8f5e9 style K fill:#ffebee


1. Preverjanje poteka

# Preveri trenutni certifikat
openssl s_client -connect gateway.example.com:443 -servername gateway.example.com 2>/dev/null | \
    openssl x509 -noout -dates
 
# Dni do poteka
echo | openssl s_client -connect gateway.example.com:443 2>/dev/null | \
    openssl x509 -noout -enddate | \
    cut -d= -f2 | \
    xargs -I {} bash -c 'echo "Dni do poteka: $(( ($(date -d "{}" +%s) - $(date +%s)) / 86400 ))"'

2a. Obnova Let's Encrypt

# Samodejno (če je certbot pravilno nastavljen)
sudo certbot renew
 
# S Pre/Post-Hook za Gateway
sudo certbot renew \
    --pre-hook "systemctl stop data-gateway" \
    --post-hook "systemctl start data-gateway"
 
# Suh tek (brez dejanske obnove)
sudo certbot renew --dry-run

Avtomatizacija prek Cron:

# /etc/cron.d/certbot-gateway
0 3 * * * root certbot renew --quiet --post-hook "systemctl reload data-gateway"

2b. Obnova pri interni CA

# Ustvari CSR
openssl req -new -key gateway.key -out gateway.csr \
    -subj "/CN=gateway.example.com/O=Example Corp"
 
# Pošlji CSR CA-ju (npr. prek PQ Crypto)
# -> Nov certifikat: gateway-new.crt

Glej: PQ Crypto: Obnova certifikata


2c. Komercialni certifikat

1. Prijava pri ponudniku (DigiCert, GlobalSign itd.) 2. Zahteva za obnovo 3. Nalaganje CSR ali generiranje novega 4. Izvedba validacije 5. Prenos novega certifikata


3. Varnostna kopija starega certifikata

# Ustvari varnostno kopijo
cp /opt/data-gateway/certs/gateway.pfx /opt/data-gateway/certs/gateway.pfx.bak.$(date +%Y%m%d)
 
# Ali za PEM
cp /opt/data-gateway/certs/cert.pem /opt/data-gateway/certs/cert.pem.bak.$(date +%Y%m%d)

4. Namestitev novega certifikata

# Format PEM
sudo cp new-cert.pem /opt/data-gateway/certs/cert.pem
sudo cp new-key.pem /opt/data-gateway/certs/key.pem
sudo chmod 600 /opt/data-gateway/certs/*.pem
 
# Format PFX
sudo cp new-gateway.pfx /opt/data-gateway/certs/gateway.pfx
sudo chmod 600 /opt/data-gateway/certs/gateway.pfx

5. Ponovni zagon Gateway

# Linux
sudo systemctl restart data-gateway
 
# Windows
Restart-Service -Name "DataGateway"
 
# Docker
docker restart gateway
 
# Kubernetes (Rolling Update)
kubectl rollout restart deployment/data-gateway -n data-gateway

6. Preverjanje

# Je nov certifikat aktiven?
echo | openssl s_client -connect gateway.example.com:443 2>/dev/null | \
    openssl x509 -noout -subject -dates
 
# Health Check
curl https://gateway.example.com/health
 
# Popoln SSL-test
openssl s_client -connect gateway.example.com:443 -servername gateway.example.com

7. Povrnitev (če je potrebno)

# Obnovi varnostno kopijo
sudo cp /opt/data-gateway/certs/gateway.pfx.bak.20241215 /opt/data-gateway/certs/gateway.pfx
 
# Ponovno zaženi Gateway
sudo systemctl restart data-gateway
 
# Preveri
curl https://gateway.example.com/health

8. Kontrolni seznam

# Točka preverjanja V
———–
1 Stari certifikat varnostno kopiran
2 Nov certifikat veljaven
3 Imena gostiteljev se ujemajo
4 Certifikat nameščen
5 Gateway ponovno zagnan
6 HTTPS deluje
7 Nadzor obveščen

Odpravljanje težav

Težava Vzrok Rešitev
————————–
Certificate mismatch Ključ se ne ujema Generiraj nov ključ
Chain incomplete Vmesni manjka Dodaj verigo
Permission denied Napačne pravice chmod 600
Gateway se ne zažene Napačno geslo Preveri appsettings.json

Samodejni nadzor

Prometheus opozorilo za potek certifikata:

- alert: GatewayCertExpiringSoon
  expr: |
    (probe_ssl_earliest_cert_expiry{job="gateway-tls"} - time()) / 86400 < 14
  for: 1h
  labels:
    severity: warning
  annotations:
    summary: "Gateway-certifikat kmalu poteče"
    description: "Certifikat poteče čez {{ $value | humanize }} dni."

Povezani Runbooks


« <- Nastavitev TLS | -> Pravila požarnega zidu »


Wolfgang van der Stille @ EMSR DATA d.o.o. - Data Gateway Professional

Zuletzt geändert: dne 29.01.2026 ob 23:39