DBAtlas · Atlas de operaciones de bases de datos

TLS / certificado caducado

Síntoma

'certificate has expired', 'SSL handshake failed', los clientes de repente no pueden conectarse (sin cambios de código).

1. ¿Dónde falla: servidor, cliente o CA?

¿Caducó el certificado del servidor, un certificado de cliente o una CA de la cadena? El síntoma suele ser 'ayer funcionaba, hoy no, y no cambió el código'.

2. Compruebe la caducidad

Lea la fecha de caducidad del certificado directamente desde el servidor (método rápido e independiente de la base de datos).

PostgreSQL

openssl s_client -connect host:5432 -starttls postgres </dev/null 2>/dev/null | openssl x509 -noout -dates

MongoDB

openssl s_client -connect host:27017 </dev/null 2>/dev/null | openssl x509 -noout -enddate

Redis

openssl s_client -connect host:6379 </dev/null 2>/dev/null | openssl x509 -noout -enddate

3. Instale y cargue el nuevo certificado

Sustituya el certificado y, en la mayoría de los casos, recargue el servicio sin reiniciarlo.

PostgreSQL

-- Renew ssl_cert_file/ssl_key_file, then:
SELECT pg_reload_conf();

MySQL

ALTER INSTANCE RELOAD TLS;

SQL Server

-- SQL Server Configuration Manager > Certificate; a service restart is required

MongoDB

// Renew the net.tls.certificateKeyFile file (at the same path), then load it without a restart (5.0+):
db.adminCommand({rotateCertificates: 1})

Redis

CONFIG SET tls-cert-file /path/new.crt
CONFIG SET tls-key-file /path/new.key

Elasticsearch

# ES watches the certificate/key files (PEM, PKCS#12) defined under xpack.security.*.ssl and
# reloads them automatically when the file at the SAME path changes (no restart needed).
# If the path, file name or keystore password changes, a rolling restart is required.
# Note: POST _nodes/reload_secure_settings is only for reloadable keystore settings, not for TLS certificates.
# Verify: check the new expiry date with openssl s_client and look in the ES logs for
# an entry showing the certificate was reloaded.

4. Verifique

Confirme con el comando openssl anterior que el handshake TLS se completa con el nuevo certificado y que la caducidad se ha extendido; conéctese de extremo a extremo con un cliente.

5. Permanente: que no vuelva a ocurrir

Configure una alerta 30 días antes de la caducidad del certificado; use renovación automática (ACME/Let's Encrypt, HashiCorp Vault, cert-manager). Automatice la recarga tras la renovación.

Abrir en DBAtlas →