大网数据广告活动
服务器运维问答

How to set up TLS to work with a Postfix Mail Server

· 52CE 我爱测

I have been tasked with implementing TLS on a Postfix email relay server for an international office. I am aware that I need to modify '/etc/postfix/main.cf' to setup TLS. We have another email relay server in the US that is setu…

问题原文

原帖链接 · MotoDave452 · CC BY-SA 3.0

I have been tasked with implementing TLS on a Postfix email relay server for an international office.

I am aware that I need to modify '/etc/postfix/main.cf' to setup TLS. We have another email relay server in the US that is setup with TLS and has the following TLS config:

# TLS parameters 'mail.company-name.com'
smtpd_tls_cert_file=/etc/ssl/certs/company-name.com.pem
smtpd_tls_key_file=/etc/ssl/private/company-name.com.key
smtpd_use_tls=yes
smtp_tls_loglevel=5
smtpd_tls_security_level=may
smtp_tls_note_starttls_offer=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

I can implement this configuration on my international office's Postfix server, so I am just wondering if all I have left to do is generate a certificate for 'mail.company-name.in' similar to the certificate that is referenced in the following lines:

smtpd_tls_cert_file=/etc/ssl/certs/company-name.com.pem
smtpd_tls_key_file=/etc/ssl/private/company-name.com.key

The new configuration would be as follows:

# TLS parameters 'mail.company-name.in'
smtpd_tls_cert_file=/etc/ssl/certs/company-name.in.pem
smtpd_tls_key_file=/etc/ssl/private/company-name.in.key
smtpd_use_tls=yes
smtp_tls_loglevel=5
smtpd_tls_security_level=may
smtp_tls_note_starttls_offer=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

Am I missing anything else that you may have noticed? Any advice will be appreciated.

Please let me know if you have any questions and I will be happy to clarify.

Thank you for your help!

已采纳解答

原帖链接 · sebix · CC BY-SA 4.0

I assume here that you do not already have a signed certificate for your domain, otherwise your question would be pointless.

If you want a certificate signed by a CA you need to go to a CA and give them your CSR, then you get a certificate. Which CA you chose is irrelevant, as long as your client's devices trust it.

To generate the CSR see you can use openssl:

openssl req -new -newkey rsa:4096 -nodes -out company-name.com.csr -keyout company-name.com.key

You need to answer a few questions, but except for the Common Name they are all irrelevant.

See also for example How do you buy an SSL Certificate? and a lot of other questions here.


EDIT:

smtpd_tls_cert_file=/etc/ssl/certs/company-name.com.pem
smtpd_tls_key_file=/etc/ssl/private/company-name.com.key

These lines define which certificate and key file to use for TLS sessions. If you want clients to verify the validity, you need to provide the certificate chain with smtpd_tls_CAfile.

smtpd_use_tls has been replaced by smtpd_tls_security_level, so use this:

smtpd_tls_security_level=may

It enables opportunistic encryption, so STARTTLS is offered but not required. I.e., when an SMTP client connects, delivering a mail to your server, it announces that STARTTLS is available. This makes sense for incoming mail from other servers. You want to set it to encrypt for submission, to require TLS for connections from clients.

smtp_tls_note_starttls_offer=yes

This will add a log line to your mail server's log that the remote SMTP server offered STARTTLS when delivering email to it.

smtp_tls_loglevel=5

Useful for debugging. Note that the docs do not recommend anything higher than 2 and 5 is not defined at all. 1 is reasonable.

For Client-Side TLS connection caching, this defines the TLS session cache database, which optimizes a bit the TLS connection setup:

smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

On the server side, the equivalent parameter smtpd_tls_session_cache_database should be removed from existing configurations, as TLS session tickets are preferred and don't need a TLS cache database.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-08-11)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。