CentOS郵件服務(wù)器搭建系列——用 SSL 對郵件加密的支持
前言
通常,我們發(fā)送的郵件在傳輸過程中都采用明文傳輸。當(dāng)發(fā)送重要信息的時候,仍然存在郵件被第三方獲取,泄露隱私及密碼等等的安全隱患。在 Web 服務(wù)器中,通過用 SSL 實(shí)現(xiàn)對 HTTPS 協(xié)議的支持,實(shí)現(xiàn)了對傳輸內(nèi)容的加密,在郵件服務(wù)器中,我們也同樣能夠依靠 SSL 來實(shí)現(xiàn)對郵件的加密,從而提高通過用郵件傳遞信息的安全性。
證書與密鑰的確認(rèn)
在這里,可以為郵件服務(wù)器建立新的證書,但為了管理上的便利性,我們直接引用 Web 服務(wù)器的證書,作為郵件服務(wù)器的證書。
首先確認(rèn) Web 服務(wù)器證書的存在。
[root@sample ~]# ls -l /etc/httpd/conf/ssl.crt/server.crt ← 確認(rèn)證書的存在性
-rw-r--r-- 1 root root 956 Oct 14 08:51 /etc/httpd/conf/ssl.crt/server.crt ← 證書存在
[root@sample ~]# ls -l /etc/httpd/conf/ssl.key/server.key ← 確認(rèn)密鑰的存在性
-rw------- 1 root root 887 Oct 14 08:49 /etc/httpd/conf/ssl.key/server.key ← 密鑰存在
如果以上確認(rèn),沒有發(fā)現(xiàn)相關(guān)的證書和密鑰的存在,請參見 “讓服務(wù)器支持安全 HTTP 協(xié)議( HTTPS )” 中的方法來建立相關(guān)的證書和密鑰。
SMTP服務(wù)器(Postfix)方面的相關(guān)設(shè)置
[1] 編輯 Postfix 的 mail.cf 配置文件。
[root@sample ~]# vi /etc/postfix/main.cf ← 編輯 Postfix 配置文件,在文尾添加如下行:
smtpd_use_tls = yessmtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scachesmtpd_tls_cert_file = /etc/httpd/conf/ssl.crt/server.crtsmtpd_tls_key_file = /etc/httpd/conf/ssl.key/server.key
[2] 編輯 Postfix 的 master.cf 配置文件。
[root@sample ~]# vi /etc/postfix/master.cf ← 編輯 master.cf
smtp inet n - n - - smtpd ← 找到此行,在行首加“#”↓#smtp inet n - n - - smtpd ← 改為此狀態(tài),禁用SMTP協(xié)議
#smtps inet n - n - - smtpd ← 找到此行,去掉行首的“#”↓smtps inet n - n - - smtpd ← 改為此狀態(tài),使用SMTPS協(xié)議
# -o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes ← 找到此行,去掉行首的“#”↓-o smtpd_tls_wrappermode=yes -o smtpd_sasl_auth_enable=yes ← 改為此狀態(tài)
[3] 編輯 Dovecot 的配置文件。
[root@sample ~]# vi /etc/dovecot.conf ← 編輯 Dovecot 的配置文件
protocols = imap pop3 ← 找到此行,將“=”后面的部分改為如下狀態(tài)↓protocols = imaps pop3s ← 改為此狀態(tài),讓其只支持imaps和pop3s協(xié)議
#ssl_disable = no ← 找到此行,去掉行首的“#”↓ssl_disable = no ← 改為此狀態(tài),讓其支持 SSL 及 TLS
#ssl_cert_file = /usr/share/ssl/certs/dovecot.pem ← 找到此行,去掉行首的“#”,并指定證書所在位置↓ssl_cert_file =/etc/httpd/conf/ssl.crt/server.crt ← 改為此狀態(tài),指定其證書為 Apache 的證書↓#ssl_key_file = /usr/share/ssl/private/dovecot.pem ← 找到此行,去掉行首的“#”,并指定密鑰所在位置
ssl_key_file = /etc/httpd/conf/ssl.key/server.key ← 改為此狀態(tài),指定其密鑰為 Apache 的密鑰
[4] 編輯防火墻規(guī)則,打開相應(yīng)端口。
[root@sample ~]# vi /etc/sysconfig/iptables ← 編輯防火墻規(guī)則
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 25 -j ACCEPT ← 找到此行,接著添加如下行:-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 465 -j ACCEPT ← 允許SMTPS的465號端口-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT ← 允許POP3S的995號端口-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT ← 允許IMAPS的993號端口
重新起動相關(guān)服務(wù),使設(shè)置生效
最后,重新啟動所有相關(guān)的服務(wù),使剛剛的設(shè)置生效。
[root@sample ~]# /etc/rc.d/init.d/postfix restart ← 重新啟動 Postfix
Shutting down postfix: [ OK ]Starting postfix: [ OK ]
[root@sample ~]# /etc/rc.d/init.d/dovecot restart ← 重新啟動 Dovecot
Stopping Dovecot Imap: [ OK ]Starting Dovecot Imap: [ OK ]
[root@sample ~]# /etc/rc.d/init.d/iptables restart ← 重新啟動 iptables
Flushing firewall rules: [ OK ]Setting chains to policy ACCEPT: filter [ OK ]Unloading iptables modules: [ OK ]Applying iptables firewall rules: [ OK ]
郵件客戶端的設(shè)置
這里,郵件客戶端的設(shè)置以 Thunderbird 為例。
* SMTP 方面:
在 SMTP 服務(wù)器設(shè)置中,選擇 SSL 方式。使用 Thunderbird 的情況下,選擇 SSL 后,端口號會自動變成 465。其它郵件客戶端軟件請根據(jù)實(shí)際情況正確設(shè)置。
相關(guān)文章:
1. java實(shí)現(xiàn)2048小游戲(含注釋)2. 詳解CSS偽元素的妙用單標(biāo)簽之美3. CSS自定義滾動條樣式案例詳解4. Ajax實(shí)現(xiàn)表格中信息不刷新頁面進(jìn)行更新數(shù)據(jù)5. Java Spring WEB應(yīng)用實(shí)例化如何實(shí)現(xiàn)6. UDDI FAQs7. PHP 面向?qū)ο蟪绦蛟O(shè)計(jì)之類屬性與類常量實(shí)現(xiàn)方法分析8. HTML <!DOCTYPE> 標(biāo)簽9. python 批量下載bilibili視頻的gui程序10. 將properties文件的配置設(shè)置為整個Web應(yīng)用的全局變量實(shí)現(xiàn)方法
