http://giayiu.adsldns.org/FreeBSD/imap_uw_POP3_IMAP4_SSL.htm
* 本文可以任意轉載,但是請不要篡名。
* 有錯誤的地方,煩請告知,謝謝。
要在 imap-uw (POP3, IMAP4) 上面建立 SSL 連線,首先您要有伺服器憑證。
假如您尚未有伺服器憑證,請買一個、要一個、請別人做一個,
或者參考其它文章自行製作。
‧自行製作憑證請注意:
憑證名稱 (Common Name) 請與伺服器名稱相同 (Server Name)。
製作好的憑證在使用上可能會出現「憑證無效」、「憑證無法驗證」等的訊息。
因為這些憑證的簽發者不是客戶端所已知且被信任的,
所以您需要將簽發此憑證的根憑證發散出去給需要用到這些憑證的使用者。
在 Internet Explorer 上,下載根憑證後開啟可以將憑證匯入系統之內,
日後此根憑證所簽發的憑證都會被信任。
注意:發散的是憑證檔 (.crt, ex. RootCA.crt),
不是 Private Key (.key, ex. RootCA.key) 檔。
‧Outlook Express 客戶端設定:
開啟 Outlook Express,點選[工具]→[帳戶]→雙點您的 Email 帳戶
POP3)→進階→勾選在 內收郵件-POP3 下方的 "這個伺服器需要安全連線-SSL"。
(連接埠→995)
IMAP4)→進階→勾選在 內收郵件-IMAP 下方的 "這個伺服器需要安全連線-SSL"。
(連接埠→993)
‧使用 Ports 安裝 imap-uw (POP3, IMAP4):
# 使用 CVSup 更新 Ports。
cd /usr/ports
make update
# 安裝 imap-uw Support SSL
cd /usr/ports/mail/imap-uw
make -DWITH_SSL_AND_PLAINTEXT install clean
‧憑證設定:
將伺服器憑證與 Private Key 放在同一個檔案。
cat HostCA.key > /usr/local/certs/imapd.pem
cat HostCA.crt >> /usr/local/certs/imapd.pem
設定憑證權限、ipop3d 憑證檔:
chmod og-rwx /usr/local/certs/imapd.pem
# pop3 與 imap4 使用同一個憑證。
ln -s /usr/local/certs/imapd.pem /usr/local/certs/ipop3d.pem
‧imap-uw 設定:
確認 /etc/services
imaps 993/tcp # imap4 protocol over TLS/SSL
imaps 993/udp
pop3s 995/tcp spop3 # pop3 protocol over TLS/SSL
pop3s 995/udp spop3
修改 /etc/inetd.conf
pop3 stream tcp nowait root /usr/local/libexec/ipop3d ipop3d
pop3s stream tcp nowait root /usr/local/libexec/ipop3d ipop3d
imap4 stream tcp nowait root /usr/local/libexec/imapd imapd
imaps stream tcp nowait root /usr/local/libexec/imapd imapd
重新啟動 inetd
kill -HUP `cat /var/run/inetd.pid`
‧憑證設定注意:
不可以更改憑證位置與檔名。(ipop3d/imapd 固定讀取路徑與檔名)