CentOS郵件服務(wù)器搭建系列——用 SSL 對(duì)郵件加密的支持
前言
通常,我們發(fā)送的郵件在傳輸過程中都采用明文傳輸。當(dāng)發(fā)送重要信息的時(shí)候,仍然存在郵件被第三方獲取,泄露隱私及密碼等等的安全隱患。在 Web 服務(wù)器中,通過用 SSL 實(shí)現(xiàn)對(duì) HTTPS 協(xié)議的支持,實(shí)現(xiàn)了對(duì)傳輸內(nèi)容的加密,在郵件服務(wù)器中,我們也同樣能夠依靠 SSL 來實(shí)現(xiàn)對(duì)郵件的加密,從而提高通過用郵件傳遞信息的安全性。
證書與密鑰的確認(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)的證書和密鑰的存在,請(qǐng)參見 “讓服務(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號(hào)端口-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 995 -j ACCEPT ← 允許POP3S的995號(hào)端口-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 993 -j ACCEPT ← 允許IMAPS的993號(hào)端口
重新起動(dòng)相關(guān)服務(wù),使設(shè)置生效
最后,重新啟動(dòng)所有相關(guān)的服務(wù),使剛剛的設(shè)置生效。
[root@sample ~]# /etc/rc.d/init.d/postfix restart ← 重新啟動(dòng) Postfix
Shutting down postfix: [ OK ]Starting postfix: [ OK ]
[root@sample ~]# /etc/rc.d/init.d/dovecot restart ← 重新啟動(dòng) Dovecot
Stopping Dovecot Imap: [ OK ]Starting Dovecot Imap: [ OK ]
[root@sample ~]# /etc/rc.d/init.d/iptables restart ← 重新啟動(dòng) 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 后,端口號(hào)會(huì)自動(dòng)變成 465。其它郵件客戶端軟件請(qǐng)根據(jù)實(shí)際情況正確設(shè)置。
相關(guān)文章:
1. css代碼優(yōu)化的12個(gè)技巧2. .NET SkiaSharp 生成二維碼驗(yàn)證碼及指定區(qū)域截取方法實(shí)現(xiàn)3. ASP中if語句、select 、while循環(huán)的使用方法4. ASP中實(shí)現(xiàn)字符部位類似.NET里String對(duì)象的PadLeft和PadRight函數(shù)5. django創(chuàng)建css文件夾的具體方法6. ASP 信息提示函數(shù)并作返回或者轉(zhuǎn)向7. 存儲(chǔ)于xml中需要的HTML轉(zhuǎn)義代碼8. jsp網(wǎng)頁實(shí)現(xiàn)貪吃蛇小游戲9. MyBatis JdbcType 與Oracle、MySql數(shù)據(jù)類型對(duì)應(yīng)關(guān)系說明10. CentOS郵件服務(wù)器搭建系列—— POP / IMAP 服務(wù)器的構(gòu)建( Dovecot )
