Bug 47421 - Ошибка Failed to load certificate при настройке TLS
Summary: Ошибка Failed to load certificate при настройке TLS
Status: CLOSED NOTABUG
Alias: None
Product: Sisyphus
Classification: Development
Component: redis (show other bugs)
Version: unstable
Hardware: x86_64 Linux
: P5 normal
Assignee: Alexey Shabalin
QA Contact: qa-sisyphus
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-08-31 13:15 MSK by Alexander Makeenkov
Modified: 2023-08-31 19:28 MSK (History)
4 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Makeenkov 2023-08-31 13:15:09 MSK
Версия пакета:
redis-7.2.0-alt1.x86_64

Шаги воспроизведения.

Установить пакет:
# apt-get install -y redis

С помощью скрипта https://github.com/redis/redis/blob/unstable/utils/gen-test-certs.sh создать сертификаты:
# ./gen-test-certs.sh && cp tests/tls/* /tmp && chown _redis: /tmp/{ca.*,client.*,openssl.*,redis.*,server.*} && echo done

Изменить конфигурационный файл и перезапустить сервис:
# cat >> /etc/redis/redis.conf <<EOF
tls-port 6379
port 0
tls-cert-file /tmp/redis.crt
tls-key-file /tmp/redis.key
tls-ca-cert-file /tmp/ca.crt
EOF

# systemctl restart redis; systemctl status redis

Получаемый результат.

Сервис не запускается. В логах ошибки:
# tail /var/log/redis/redis-server.log 
11158:M 31 Aug 2023 12:57:39.486 # Failed to load certificate: /tmp/redis.crt: error:80000002:system library::No such file or directory
11158:M 31 Aug 2023 12:57:39.486 # Failed to configure TLS. Check logs for more info.
11163:C 31 Aug 2023 12:57:39.734 * Supervised by systemd. Please make sure you set appropriate values for TimeoutStartSec and TimeoutStopSec in your service unit.
11163:C 31 Aug 2023 12:57:39.734 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
11163:C 31 Aug 2023 12:57:39.734 * Redis version=7.2.0, bits=64, commit=00000000, modified=0, pid=11163, just started
11163:C 31 Aug 2023 12:57:39.734 * Configuration loaded
11163:M 31 Aug 2023 12:57:39.734 * monotonic clock: POSIX clock_gettime
11163:M 31 Aug 2023 12:57:39.735 * Running mode=standalone, port=6379.
11163:M 31 Aug 2023 12:57:39.735 # Failed to load certificate: /tmp/redis.crt: error:80000002:system library::No such file or directory
11163:M 31 Aug 2023 12:57:39.736 # Failed to configure TLS. Check logs for more info

Доступ к сертификату для пользователя _redis есть:
# su - _redis -s /bin/bash -c 'ls /tmp/redis.crt'

Проблема не воспроизводится в p10 на версии 6.2.8-alt2 при выполнении аналогичной настройки.
Comment 1 Alexander Makeenkov 2023-08-31 17:37:16 MSK
Ошибка не воспроизводится, если запускать не через systemd сервис, а напрямую от пользователя:
# su - _redis -s /bin/bash -c '/usr/sbin/redis-server --tls-port 6377 --tls-cert-file /tmp/redis.crt --tls-key-file /tmp/redis.key --tls-ca-cert-file /tmp/ca.crt'

Так же, ошибка не воспроизводится и с systemd сервисом, если не класть сертификаты в /tmp, а в какую-либо другую папку, поскольку:
# systemctl cat redis | grep PrivateTmp
PrivateTmp=true
Comment 2 Alexey Shabalin 2023-08-31 19:28:30 MSK
PrivateTmp=true так и задумано.
Тем более класть приватные сертификаты в tmp, ну это так себе идея.