TLS / certificado expirado
Sintoma
'certificate has expired', 'SSL handshake failed', os clientes de repente não conseguem se conectar (sem mudança de código).
1. Onde quebra: servidor, cliente ou CA?
Foi o certificado do servidor que expirou, um certificado de cliente ou uma CA da cadeia? O sintoma costuma ser 'funcionava ontem, hoje não funciona, nenhum código mudou'.
2. Verifique a expiração
Leia a data de expiração do certificado direto do servidor (um método rápido e independente do banco).
PostgreSQL
openssl s_client -connect host:5432 -starttls postgres </dev/null 2>/dev/null | openssl x509 -noout -datesMongoDB
openssl s_client -connect host:27017 </dev/null 2>/dev/null | openssl x509 -noout -enddateRedis
openssl s_client -connect host:6379 </dev/null 2>/dev/null | openssl x509 -noout -enddate3. Instale e carregue o novo certificado
Substitua o certificado e, na maioria dos casos, recarregue o serviço sem reiniciá-lo.
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 requiredMongoDB
// 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.keyElasticsearch
# 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 com o comando openssl acima que o handshake TLS funciona com o novo certificado e que a expiração foi estendida; conecte de ponta a ponta com um cliente.
5. Definitivo: nunca mais
Configure um alerta 30 dias antes da expiração do certificado; use renovação automática (ACME/Let's Encrypt, HashiCorp Vault, cert-manager). Automatize o reload após a renovação.