搜索域名/功能..
历史记录

帮助中心

Postfix中的SSL配置指南

更新时间:2024-11-12
<p>生成证书请求</p> <p>1. 下载CSR生成工具</p> <p>您需要使用CSR生成工具来创建证书请求。</p> <p>下载AutoCSR:</p> <p>http://verisign.itrus.com.cn/soft/autocsr.rar</p> <p>2.使用openssl命令来完成申请:</p> <p>[root@mail misc]# openssl genrsa -out mailkey.pem 2048</p> <p>[root@mail misc]# openssl req -new -key mailkey.pem -out cert.csr</p> <p>#cert.csr文件为 csr文件,请将其发送给聚名工作人员</p> <p>Generating a 2048 bit RSA private key</p> <p>++++++</p> <p>……++++++</p> <p>writing new private key to 'mailkey.pem'</p> <p>-----</p> <p>You are about to be asked to enter information that will be incorporated</p> <p>into your certificate request.</p> <p>What you are about to enter is what is called a Distinguished Name or a DN.</p> <p>There are quite a few fields but you can leave some blank</p> <p>For some fields there will be a default value,</p> <p>If you enter '.', the field will be left blank.</p> <p>-----</p> <p>Country Name (2 letter code) [GB]:CN :国家缩写 CN为中国的缩写</p> <p>State or Province Name (full name) [Berkshire]:Shandong :省市名称</p> <p>Locality Name (eg, city) [Newbury]:jinan :市区名称</p> <p>Organization Name (eg, company) [My Company Ltd]:test :公司英文名称</p> <p>Organizational Unit Name (eg, section) []:tech :部门名称</p> <p>Common Name (eg, your name or your server's hostname) []:admin :通用名称,完整域名</p> <p>Email Address []:admin@test.com :邮箱地址,可选填项</p> <p>Please enter the following 'extra' attributes</p> <p>to be sent with your certificate request</p> <p>A challenge password []:</p> <p>An optional company name []:</p> <p>安装证书到postfix,并配置postfix</p> <p>cp demoCA/cacert.pem /etc/postfix/</p> <p>cp mailkey.pem /etc/postfix/</p> <p>cp mail_signed_cert.pem /etc/postfix/</p> <p>vi /etc/postfix/main.cf 编辑配置文件,增加如下几行:</p> <p>上半部分的配置是系统作为服务端,接收客户端和其他邮件服务器时如何启用tls;下版半部分服务器作为客户端对外发送邮件也启用tls</p> <p>smtpd_use_tls = yes</p> <p>smtpd_tls_key_file = /etc/postfix/mailkey.pem 私钥文件的配置</p> <p>smtpd_tls_cert_file = /etc/postfix/mail_signed_cert.pem 服务器证书文件的配置</p> <p>smtpd_tls_CAfile = /etc/postfix/cacert.pem 中间级证书文件的配置</p> <p>smtpd_tls_loglevel = 1</p> <p>smtpd_tls_received_header= yes</p> <p>smtpd_tls_security_level = may</p> <p>smtpd_use_tls=yes</p> <p>smtp_tls_note_starttls_offer = yes</p> <p>smtp_tls_key_file = /etc/postfix/mailkey.pem</p> <p>smtp_tls_cert_file = /etc/postfix/mail_signed_cert.pem</p> <p>smtp_tls_CAfile = /etc/postfix/cacert.pem</p> <p>说明一个参数</p> <p>smtpd_tls_security_level = may</p> <p>这样设置你的SMTP可以加密可以不加密,不要设置成</p> <p>smtpd_tls_security_level = encrypt</p> <p>否则就不响应非加密的请求了,这样不行,因为如果你是一个MTA的话,大部分跟你通信的MTA都没有encrypt的。</p> <p>五。 重启postfix服务,就可以了。</p> <p>service postfix restart</p> <p>六。 如果需要打开465(smtps)端口,则需要进行进行如下操作</p> <p>修改/etc/postfix/master.cf文件</p> <p>在smtp inet n - n - - smtpd行下,加入如下一行:</p> <p>smtps inet n - n - - smtpd -o smtpd_tls_wrappermode=yes</p> <p>七。 强制使用TLS发信</p> <p>通过以上的配置启用了tls发信设置,那麽系统发信时会检查对方服务器是否支持tls,如果支持则使用tls传输,否则采用正常的邮件发送。postfix可以设置向某些域发送强制使用TLS,如果对方不支持则邮件将延迟发送,如下是操作方法:</p> <p>1. 创建/etc/postfix/tls_policy文件,加入如下一行</p> <p>test.com encrypt</p> <p>2. 执行postmap tls_policy</p> <p>3. 修改main.cf文件,增加如下行</p> <p>smtp_tls_policy_maps = hash:/etc/postfix/tls_policy</p> <p>注:该选项会忽略smtp_use_tls,即无论smtp_use_tls是yes还是no,都会启用smtp_tls_policy_maps</p> <p>4. 重启postfix服务</p>