DBAtlas · Атлас эксплуатации баз данных

TLS / истёк сертификат

Симптом

'certificate has expired', 'SSL handshake failed', клиенты внезапно не могут подключиться (без изменений в коде).

1. Где сбой: сервер, клиент или CA?

Истёк сертификат сервера, клиентский сертификат или CA в цепочке? Типичный симптом: «вчера работало, сегодня нет, код не менялся».

2. Проверьте срок действия

Прочитайте дату истечения сертификата прямо с сервера (быстрый способ, не зависящий от СУБД).

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. Установите и загрузите новый сертификат

Замените сертификат и в большинстве случаев перезагрузите конфигурацию сервиса без перезапуска.

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. Проверьте

Убедитесь командой openssl выше, что TLS handshake с новым сертификатом проходит и срок действия продлён; выполните сквозное подключение клиентом.

5. Навсегда: больше никогда

Настройте оповещение за 30 дней до истечения сертификата; используйте автоматическое продление (ACME/Let's Encrypt, HashiCorp Vault, cert-manager). Автоматизируйте перезагрузку после продления.

Открыть в DBAtlas →