Dovecot은 TLS 인증서를 읽을 수 없습니다

Dovecot은 TLS 인증서를 읽을 수 없습니다

내 CentOS 7 시스템에서 TLS가 필요한 비둘기장을 실행하려고 합니다. 이를 위해 개인 키와 인증서를 만들었습니다.

[root@homeserver /]# ls -lZ indernet/cert/homeserver.*
-r--r--r--. root certuser system_u:object_r:default_t:s0   indernet/cert/homeserver.crt
-r--r-----. root certuser system_u:object_r:default_t:s0   indernet/cert/homeserver.key
[root@homeserver /]#

dovecot이 실제로 파일을 로드하도록 하기 위해 /etc/dovecot/conf.d/10-ssl.conf에 다음 줄이 포함되어 있는지 확인했습니다.

ssl=required
ssl_key=</indernet/cert/homeserver.key
ssl_cert=</indernet/cert/homeserver.crt

문제가 되는 부분: Dovecot을 시작할 수 없습니다. 이 오류로 인해 실패합니다.:

dovecot: doveconf: Fatal: Error in configuration file /etc/dovecot/conf.d/10-ssl.conf line 14: ssl_key: Can't open file /indernet/cert/homeserver.key: Permission denied

인증서와 키의 파일 권한을 수정하려고 했습니다.https://doc.dovecot.org/configuration_manual/dovecot_ssl_configuration/), 777에도 아무런 변화가 없습니다. 누군가 SELinux가 액세스를 방해할 수 있다고 제안했고 위에서 볼 수 있듯이 unconfined_u:object_r:default_t:s0과 system_u:object_r:default_t:s0을 구성했습니다. 변경 없음.

이제 놀라운 부분: 매우 궁금해서 /usr/lib/systemd/system/dovecot.service를 편집하여 포함시켰습니다.

ExecStart=/bin/strace /usr/sbin/dovecot

그런 다음 /var/log/messages에서 인증서와 키가 액세스되고 로드되는 것을 볼 수 있습니다. 그리고 비둘기장도 작동합니다. 그러나 추적을 다시 제거하면 동일한 문제가 남습니다.

여기서 무슨 일이 일어나고 있는 걸까요?

답변1

SELinux가 키에 대한 액세스를 거부했기 때문에 키를 읽을 수 없습니다.

문제를 해결하려면,복사cp( 또는 사용 mv -Z) SELinux가 TLS 키와 인증서가 저장될 것으로 예상하는 디렉토리, 즉 /etc/pki/tls하위 디렉토리에 대한 키. cp또는 를 사용한 경우 새 파일은 올바른 SELinux 컨텍스트를 갖게 됩니다 mv -Z. 그런 다음 Dovecot 구성에서 파일 위치를 업데이트합니다.

관련 정보