Score:1

IMAP and SMTP Still use Self Signed SSL even I have issued a Mail Server SSL in Cyberpanel

iq flag

I using cyberpanel on CentOS 7 and I setup SSL for my postfix and dovecot. But I still got "SSL Invalid" caused the self-signed SSL even I have configure SSL using Lets Encrypt.

This is /etc/postfix/main.cf

smtpd_tls_cert_file = /etc/letsencrypt/live/mail.domain.net/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/mail.domain.net/privkey.pem

This is /etc/dovecot/dovecot.conf

ssl_cert = </etc/letsencrypt/live/mail.domain.net/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.domain.net/privkey.pem
....
local_name mail.domain.net {
        ssl_cert = </etc/letsencrypt/live/mail.domain.net/fullchain.pem
        ssl_key = </etc/letsencrypt/live/mail.domain.net/privkey.pem
}

local_name mail.sub.domain.net {
        ssl_cert = </etc/letsencrypt/live/mail.sub.domain.net/fullchain.pem
        ssl_key = </etc/letsencrypt/live/mail.sub.domain.net/privkey.pem
}

This is /etc/dovecot/conf.d/10-ssl.conf

ssl = required
ssl_cert = </etc/letsencrypt/live/mail.domain.net/fullchain.pem
ssl_key = </etc/letsencrypt/live/mail.domain.net/privkey.pem

All file has pointed to correct SSL file. However, when I was trying to login IMAP and SMTP using SSL, I got error: SSL Invalid caused self-signed certificate www.example.com (not mail.domain.net).

When I check using command: openssl s_client -servername mail.domain.net -connect mail.domain.net:993

CONNECTED(00000003)
depth=0 C = US, ST = Denial, L = Springfield, O = Dis, CN = www.example.com
verify error:num=18:self signed certificate
verify return:1
depth=0 C = US, ST = Denial, L = Springfield, O = Dis, CN = www.example.com
verify return:1
---
Certificate chain
 0 s:/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com
   i:/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com
---
Server certificate
-----BEGIN CERTIFICATE-----
MIIDizCCAnOgAwIBAgIJAJDbjRXJistMMA0GCSqGSIb3DQEBCwUAMFwxCzAJBgNV
BAYTAlVTMQ8wDQYDVQQIDAZEZW5p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kubJm
wd31QwGht2wX/yGBtRNk+fxrA4ObKgva/bRLYpcZr6axva+vMFmJ2bVC1W3pUmU=
-----END CERTIFICATE-----
subject=/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com
issuer=/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com
---
No client certificate CA names sent
Peer signing digest: SHA512
Server Temp Key: ECDH, P-256, 256 bits
---
SSL handshake has read 1590 bytes and written 441 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES256-GCM-SHA384
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
    Protocol  : TLSv1.2
    Cipher    : ECDHE-RSA-AES256-GCM-SHA384
    Session-ID: 88F2CCFDE63FE391E9824F596E0C8300E44CB306F969E2A1C0AFE3B75E5A4D74
    Session-ID-ctx: 
    Master-Key: E22198E25F15AA193B9E73446CB934276DF90987DFC75B1B74DDAF3247CA8436CDB93B3274102188B3470DF1A4EFB0D1
    Key-Arg   : None
    Krb5 Principal: None
    PSK identity: None
    PSK identity hint: None
    TLS session ticket lifetime hint: 300 (seconds)
    TLS session ticket:
    0000 - e6 78 ae 14 e1 04 0d b4-64 82 65 9e 14 ad 32 9c   .x......d.e...2.
    0010 - f3 f0 c2 fd f9 12 5b bf-0f 50 75 79 64 5c bb ba   ......[..Puyd\..
    0020 - 31 f6 37 bd 1c b2 e7 dc-d9 02 c7 53 f4 f9 0c a6   1.7........S....
    0030 - d4 51 6a 60 6b 34 04 41-fd b3 7d 53 14 ff 1d b4   .Qj`k4.A..}S....
    0040 - a2 82 67 6e da d7 80 02-b0 9f 6d 82 b4 17 72 cf   ..gn......m...r.
    0050 - 30 05 54 fc 8c be 60 6d-e5 0f b8 25 04 f3 43 6d   0.T...`m...%..Cm
    0060 - 7e 13 f1 85 02 03 90 a2-50 82 64 43 aa 79 b8 ee   ~.......P.dC.y..
    0070 - 86 08 ef 7a ac 4b c7 86-57 bc 09 a4 9a bb 23 92   ...z.K..W.....#.
    0080 - cb 18 74 a4 90 c5 b1 8b-39 3c cc 69 ee e8 fb 08   ..t.....9<.i....
    0090 - 60 93 ea 17 35 d5 58 0d-ee 1b 68 c2 98 d0 e9 9c   `...5.X...h.....
    00a0 - f5 a7 24 9b 29 0a 48 6b-70 f8 a5 9a 7c e5 e8 88   ..$.).Hkp...|...

    Start Time: 1624855926
    Timeout   : 300 (sec)
    Verify return code: 18 (self signed certificate)
---
+OK Dovecot ready.

This is log on mail server. systemctl status postfix -l

230, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<RLYR5sLFeh62/Xx7>
Jun 28 00:42:37 mail-domain-net dovecot[574952]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=182.253.XXX.XXX, lip=10.5.224.230, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<WF4U5sLFlym2/Xx7>
Jun 28 00:42:38 mail-domain-net dovecot[574952]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=182.253.XXX.XXX, lip=10.5.224.230, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<nasX5sLFoim2/Xx7>
Jun 28 00:42:38 mail-domain-net dovecot[574952]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=182.253.XXX.XXX, lip=10.5.224.230, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<BFYY5sLFrCm2/Xx7>
Jun 28 00:42:38 mail-domain-net dovecot[574952]: imap-login: Disconnected (no auth attempts in 0 secs): user=<>, rip=182.253.XXX.XXX, lip=10.5.224.230, TLS handshaking: SSL_accept() failed: error:14094416:SSL routines:ssl3_read_bytes:sslv3 alert certificate unknown: SSL alert number 46, session=<YQkZ5sLFrSm2/Xx7>

Please help me, which file or config should I check.

jp flag
Dom
Where do you see in logs the self signed problem ? I see a client in SSLv3, which should be forbid as obsolete technology
vidarlo avatar
ar flag
Did you restart dovecot and postfix after updating certificate? What is the output of `openssl s_client -starttls smtp -showcerts -connect mail.domain.net:25`? If you don't redact domains, people here can do such checks for you and provide an answer...
djdomi avatar
za flag
ssl_cert = </etc/letsenc really?
xdnroot avatar
iq flag
@Dom I saw that error in GMAIL apps and in python imaplib library.
xdnroot avatar
iq flag
@vidarlo yes, I have restarted dovecot and postfix after update config and certificate. However the output of openssl s_client -starttls smtp -showcerts -connect mail.domain.net:25 still using www.example.com (self-signed certificate).
xdnroot avatar
iq flag
@djdomi yes, what's wrong with that?
djdomi avatar
za flag
@xdnroot `ssl_cert = *<*/etc/letsenc` MUST be a misspelled, as `ssl_cert = /etc/letsenc` should it be - i see that it seems that you have a LOT of ** < ** in your config which dont have to be there!!
xdnroot avatar
iq flag
@djdomi I just follow the default config format and it confirmed in this docs: https://doc.dovecot.org/configuration_manual/dovecot_ssl_configuration/
djdomi avatar
za flag
strange behavior, never seen something like that
Paul avatar
cn flag
Have you tried any CyberPanel support?
Score:0
iq flag

I solved that problem by doing the following stuff:

1. Configure PTR Record I request the server provider to add PTR record for my IP address. So, when you lookup your IP, it will returned this:

$ nslookup 116.193.250.253                                                                                                                   130 ⨯
253.250.193.116.in-addr.arpa    name = mail.yourprimarymailserverdomain.com.
253.250.193.116.in-addr.arpa    name = mail.yoursecondarymailserverdomain.com.

Alright, I used two domains for my email server. If you still get self-signed SSL, go to 2nd step.

2. Configure Postfix and Dovecot manually.

Let say you are on some of the old versions of CyberPanel or you have already created a website before upgrading to v1.9.4. You can go ahead and create mail.domain.com as a child-domain to your master domain also make sure to issue SSL for this domain.

Step 1: Open the file /etc/postfix/main.cf using any editor

sudo nano /etc/postfix/main.cf

Step 2: Comment the following two lines in that file by adding an # sign at the beginning.

# smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem 
# smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem

Step 3: Add the following lines after changing. Remember to replace YourPrimaryMailServerDomain with the your own domain.

# provide the primary certificate for the server, to be used for outgoing connections 
smtpd_tls_chain_files = /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/privkey.pem, /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/fullchain.pem

Step 4: In order to support SNI you need to add the following lines at the end

# provide the map to be used when SNI support is enabled 
tls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map

After all the above steps your files should look like this

# smtpd_tls_cert_file = /etc/pki/dovecot/certs/dovecot.pem
# smtpd_tls_key_file = /etc/pki/dovecot/private/dovecot.pem
# provide the primary certificate for the server, to be used for outgoing connections
smtpd_tls_chain_files = /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/privkey.pem, /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/fullchain.pem
# provide the map to be used when SNI support is enabled
tls_server_sni_maps = hash:/etc/postfix/vmail_ssl.map

Step 5: Create a new file in /etc/postfix with the name of vmail_ssl.map

sudo touch /etc/postfix/vmail_ssl.map

Step 6: Edit the file to add your domain’s SSL certificates to the list like this

mail.yourprimarymailserverdomain.com /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/privkey.pem /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/fullchain.pem

Step 7 (Optional): If you have more than one domain to be supported add all of them one per line. The resulting file should look like this

# Compile with postmap -F hash:/etc/postfix/vmail_ssl.map when updating
# One host per line
mail.yourprimarymailserverdomain.com /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/privkey.pem /etc/letsencrypt/live/mail.yourprimarymailserverdomain.com/fullchain.pem
mail.yoursecondarymailserverdomain.com /etc/letsencrypt/live/mail.yoursecondarymailserverdomain.com/privkey.pem /etc/letsencrypt/live/mail.yoursecondarymailserverdomain.com/fullchain.pem
# add more domains with keys and certs as needed

Step 8: Open /etc/dovecot/dovecot.conf

sudo nano /etc/dovecot/dovecot.conf

Step 9: Append the following to the end of the file, replace domain.com with your own domain.

local_name mail.domain.com {
  ssl_cert = </etc/letsencrypt/live/mail.domain.com/fullchain.pem
  ssl_key = </etc/letsencrypt/live/mail.domain.com/privkey.pem
}

Step 10: Re-compile postmap with SNI using the following command

postmap -F hash:/etc/postfix/vmail_ssl.map

Step 11: Restart Postfix.

systemctl restart postfix

Step 12: Restart Dovecot

systemctl restart dovecot

Connect again using a mail client and you should not see the error.

Reference: https://cyberpanel.net/docs/6-self-signed-ssl-error-on-outlook-thunderbird/

Good luck. :)

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.