一个 IP 上的 Postfix、多域和多证书

DSX*_*DSX 8 ssl postfix ssl-certificate

我有一个 postfix 服务器,它有多个域,我想每个都有一个特定的证书。我的服务器只有一个IP。

我找到了一个多 IP 的解决方案,但没有我不知道如何做到这一点。

  • 服务器:Debian 9
  • 后缀:3.1.8

小智 12

如果您使用 Postfix >=3.4,请考虑以下改编自此链接的步骤:

Step 1: Comment out the top two lines and add the follow lines to /etc/postfix/main.cf:

---
# 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 (note the indentation)
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 2: Create the file /etc/postfix/vmail_ssl.map with the following:

---
# 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 3: Run postmap -F hash:/etc/postfix/vmail_ssl.map.

Step 4: Run systemctl restart postfix.

Step 5: Now test your domains' SSLs! For each of your domains, run the following command: openssl s_client -connect localhost:25 -servername mail.mydomainname.com -starttls smtp
Run Code Online (Sandbox Code Playgroud)


per*_*ris 8

对于那些不知道的人来说,每次证书更改时都需要重建 SNI 表,因为生成用于导入postmap -F文件内容的基础表(它不仅仅存储对文件名的引用)。

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


San*_*ton 4

据我所知,postfix 中没有可用的 SNI。然而。文档 ( http://www.postfix.org/TLS_README.html ) 说“没有计划在 Postfix SMTP 服务器中实现 SNI”,尽管 Victor 在 1 月份提到他希望在 postfix 3.4 中添加 SNI 支持。备择方案 :

  • 多个IP
  • 包含所有域名的证书。

此外,为所有域使用相同的 MX 也没有什么问题。MX 主机名是您的服务域或其他名称。还将 helo/ehlo 名称配置为相同/相似的主机名。如果这对 GoogleApps 和其他主要电子邮件提供商有好处,那么对我们也有好处。