Postfix warning: cannot get RSA certificate from file “../dovecot.pem”

Case study:
- Máy chủ sử dụng Cyberpanel với webmail snappymail trên CentOS 7
- Tình trạng: đăng nhập vào webmail thực hiện gửi mail thì báo lỗi “Can’t sent email”
Log lỗi:
journalctl -f | grep postfix
Apr 07 13:59:53 postfix<sp/submission/smtpd[178329]: warning: cannot get RSA certificate from file “/etc/pki/dovecot/certs/dovecot.pem”: disabling TLS support
Apr 07 13:59:53 postfix/submission/smtpd[178329]: warning: TLS library problem: error:0200100D:system library:fopen:Permission denied:crypto/bio/bss_file.c:288:fopen(‘/etc/pki/dovecot/certs/dovecot.pem’,’r’):
Apr 07 13:59:53 postfix/submission/smtpd[178329]: warning: TLS library problem: error:20074002:BIO routines:file_ctrl:system lib:crypto/bio/bss_file.c:290:
Apr 07 13:59:53 postfix/submission/smtpd[178329]: warning: TLS library problem: error:140DC002:SSL routines:use_certificate_chain_file:system lib:ssl/ssl_rsa.c:596:
Apr 07 13:59:53 postfix/submission/smtpd[178329]: connect from localhost[::1]
Apr 07 13:59:53 postfix/cleanup[178333]: B4AAA10C15D0: message-id=<20230407065953.B4AAA10C15D0@***.vn>
Apr 07 13:59:53 postfix/submission/smtpd[178329]: disconnect from localhost[::1] ehlo=1 starttls=0/1 quit=1 commands=2/3
Apr 07 13:59:53 postfix/qmgr[37380]: B4AAA10C15D0: from=<double-bounce@***.vn>, size=801, nrcpt=1 (queue active)
Kiểm tra thêm audit log
grep “denied” /var/log/audit/audit.log
type=AVC msg=audit(1680855352.418:1839064): avc: denied { read } for pid=188580 comm=”smtpd” name=”dovecot.pem” dev=”sda2″ ino=10487049 scontext=system_u:system_r:postfix_smtpd_t:s0 tcontext=system_u:object_r:dovecot_cert_t:s0 tclass=lnk_file permissive=1
Nguyên nhân: Liên quan đến quyền đọc file /etc/pki/dovecot/certs/dovecot.pem, kiểm tra SELinux bằng lệnh bên dưới
sestatus
Kết quả thấy SELinux đang enable, vậy có thể do SElinux giới hạn quyền đọc file, disable tạm SELinux bằng lệnh:
sudo setenforce 0
Thử lại gửi mail thì OK
Để disable SELinux luôn thì thực hiện mở file /etc/selinux/config và cấu hình SELINUX=disabled sau đó reboot server
Chúc các bạn thành công.
========================================
P.A Việt Nam cung cấp đa dạng các cấu hình Máy Chủ Ảo và Máy Chủ Riêng
Cloud Server
Cloud Server Pro
Máy Chủ Riêng
Tham khảo các ưu đãi: https://www.pavietnam.vn/vn/tin-khuyen-mai/
Tham khảo thêm các bài viết hướng dẫn khác tại https://kb.pavietnam.vn/