帮助中心

Postfix中的SSL配置指南

更新时间:2020-06-09

生成证书请求

1. 下载CSR生成工具

您需要使用CSR生成工具来创建证书请求。

下载AutoCSR:

http://verisign.itrus.com.cn/soft/autocsr.rar

2.使用openssl命令来完成申请:

[root@mail misc]# openssl genrsa -out mailkey.pem 2048

[root@mail misc]# openssl req -new -key mailkey.pem -out cert.csr

#cert.csr文件为 csr文件,请将其发送给聚名工作人员

Generating a 2048 bit RSA private key

++++++

……++++++

writing new private key to 'mailkey.pem'

-----

You are about to be asked to enter information that will be incorporated

into your certificate request.

What you are about to enter is what is called a Distinguished Name or a DN.

There are quite a few fields but you can leave some blank

For some fields there will be a default value,

If you enter '.', the field will be left blank.

-----

Country Name (2 letter code) [GB]:CN :国家缩写 CN为中国的缩写

State or Province Name (full name) [Berkshire]:Shandong :省市名称

Locality Name (eg, city) [Newbury]:jinan :市区名称

Organization Name (eg, company) [My Company Ltd]:test :公司英文名称

Organizational Unit Name (eg, section) []:tech :部门名称

Common Name (eg, your name or your server's hostname) []:admin :通用名称,完整域名

Email Address []:admin@test.com :邮箱地址,可选填项

Please enter the following 'extra' attributes

to be sent with your certificate request

A challenge password []:

An optional company name []:

安装证书到postfix,并配置postfix

cp demoCA/cacert.pem /etc/postfix/

cp mailkey.pem /etc/postfix/

cp mail_signed_cert.pem /etc/postfix/

vi /etc/postfix/main.cf 编辑配置文件,增加如下几行:

上半部分的配置是系统作为服务端,接收客户端和其他邮件服务器时如何启用tls;下版半部分服务器作为客户端对外发送邮件也启用tls

smtpd_use_tls = yes

smtpd_tls_key_file = /etc/postfix/mailkey.pem 私钥文件的配置

smtpd_tls_cert_file = /etc/postfix/mail_signed_cert.pem 服务器证书文件的配置

smtpd_tls_CAfile = /etc/postfix/cacert.pem 中间级证书文件的配置

smtpd_tls_loglevel = 1

smtpd_tls_received_header= yes

smtpd_tls_security_level = may

smtpd_use_tls=yes

smtp_tls_note_starttls_offer = yes

smtp_tls_key_file = /etc/postfix/mailkey.pem

smtp_tls_cert_file = /etc/postfix/mail_signed_cert.pem

smtp_tls_CAfile = /etc/postfix/cacert.pem

说明一个参数

smtpd_tls_security_level = may

这样设置你的SMTP可以加密可以不加密,不要设置成

smtpd_tls_security_level = encrypt

否则就不响应非加密的请求了,这样不行,因为如果你是一个MTA的话,大部分跟你通信的MTA都没有encrypt的。

五。 重启postfix服务,就可以了。

service postfix restart

六。 如果需要打开465(smtps)端口,则需要进行进行如下操作

修改/etc/postfix/master.cf文件

在smtp inet n - n - - smtpd行下,加入如下一行:

smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes

七。 强制使用TLS发信

通过以上的配置启用了tls发信设置,那麽系统发信时会检查对方服务器是否支持tls,如果支持则使用tls传输,否则采用正常的邮件发送。postfix可以设置向某些域发送强制使用TLS,如果对方不支持则邮件将延迟发送,如下是操作方法:

1. 创建/etc/postfix/tls_policy文件,加入如下一行

test.com encrypt

2. 执行postmap tls_policy

3. 修改main.cf文件,增加如下行

smtp_tls_policy_maps = hash:/etc/postfix/tls_policy

注:该选项会忽略smtp_use_tls,即无论smtp_use_tls是yes还是no,都会启用smtp_tls_policy_maps

4. 重启postfix服务

联系我们

服务热线(工作日9:00-18:00)

400-9972-996

扫码添加客服微信

客户经理推荐

昵称:莹莹

QQ:

电话:17756009013

在线咨询