Topic: iRedMail messes up the SSL certificates on it's own
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.6.2 PGSQL edition.
- Deployed with iRedMail Easy or the downloadable installer? downloadable installer
- Linux/BSD distribution name and version: FreeBSD 13.1-RELEASE-p6 GENERIC amd64
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): PGSQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
My mailserver suddenly stopped working and I haven't been logged on this server for about a month. It seems when iRedMail tries to renew the certificates using Let's Encrypt it somehow fails. This is the second time that it's happened. Last time I was able to revive the old certificates using a ZFS snapshot. And, I had a backup. I copied back the certs and now everything works as expected. The issue is the certificates are going to expire on 26th of May and probably the mail server stops again.
Here is the exact problem:
Inside the /etc/ssl/private when I run the following command, I see:
$ ls -lah
total 19
drwxr-xr-x 2 root wheel 5B Dec 21 02:17 .
drwxr-xr-x 5 root wheel 9B Dec 21 00:18 ..
-rw------- 1 postgres postgres 3.2K Mar 25 02:13 iRedMail_PostgreSQL.key
lrwxr-xr-x 1 root wheel 57B Dec 21 02:17 iRedMail.key -> /usr/local/etc/letsencrypt/live/somedomain.com/privkey.pem
-rw-r--r-- 1 root wheel 3.2K Mar 25 02:13 iRedMail.key.bak
The original backups I've had is just a plain file not a symlink. I also copied back the iRedMail.crt in the certs folder (it was not a symlink). Rebooted and now works. But, I'm afraid this is a bug in iRedMail that somehow I don't understand what's going on.
Sample Nginx logs:
2023/04/30 20:58:45 [emerg] 37812#100284: SSL_CTX_use_PrivateKey("/etc/ssl/private/iRedMail.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
2023/04/30 20:58:45 [emerg] 65596#100284: SSL_CTX_use_PrivateKey("/etc/ssl/private/iRedMail.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
2023/05/01 10:26:28 [emerg] 1698#100424: SSL_CTX_use_PrivateKey("/etc/ssl/private/iRedMail.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
2023/05/01 10:29:39 [emerg] 21233#100337: SSL_CTX_use_PrivateKey("/etc/ssl/private/iRedMail.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
2023/05/01 10:30:16 [emerg] 45523#100388: SSL_CTX_use_PrivateKey("/etc/ssl/private/iRedMail.key") failed (SSL: error:0B080074:x509 certificate routines:X509_check_private_key:key values mismatch)
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.