Postfix Dovecot POP/IMAP over SSL

この章を始める前に下記の設定が必要です
「暗号化通信 OpenSSL インストール」 「Apache2 インストール」 ※自己証明書保存先 「Postfix Dovecot インストール」
自己証明書作成
[root@centos ~]# cd /etc/pki/tls/certs/
[root@centos certs]# openssl req -new -x509 -days 3650 -key server.key -out mail.crt
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) [XX]:JP ←国名
State or Province Name (full name) []:Tokyo ←都道府県名
Locality Name (eg, city) [Default City]:Shibuya ←市区町村名
Organization Name (eg, company) [Default Company Ltd]:server-manual.com ←ホスト名(または会社名)
Organizational Unit Name (eg, section) []: ←空エンター
Common Name (eg, your name or your server's hostname) []:mail.server-manual.com ←ホスト名(または管理者名)
Email Address []:postmaster@server-manual.com ←管理者メールアドレス
[root@centos certs]# chmod 400 mail.crt
ブラウザインポート用バイナリDER作成
[root@centos certs]# openssl x509 -in mail.crt -out /var/www/html/mail.der -outform DER
[root@centos certs]# cd
main.cf編集
[root@centos ~]# vi /etc/postfix/main.cf
↓最終行に下記を記入
# TLS configuration
smtpd_use_tls = yes
smtpd_tls_cert_file = /etc/pki/tls/certs/mail.crt
smtpd_tls_key_file = /etc/pki/tls/certs/server.key
smtpd_tls_session_cache_database = btree:/etc/postfix/smtpd_scache
master.cf編集
[root@centos ~]# vi /etc/postfix/master.cf
↓下記をコメントアウト
#submission inet n       -       n       -       -       smtpd
#  -o syslog_name=postfix/submission
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes

↓下記をコメント解除
smtps     inet  n       -       n       -       -       smtpd
  -o syslog_name=postfix/smtps
  -o smtpd_tls_wrappermode=yes
  -o smtpd_sasl_auth_enable=yes

tlsmgr    unix  -       -       n       1000?   1       tlsmgr ←コメント解除
Postfix再起動
[root@centos ~]# systemctl restart postfix
vi /etc/dovecot/conf.d/10-ssl.conf編集
[root@centos ~]# vi /etc/dovecot/conf.d/10-ssl.conf
#ssl = yes

ssl = yes ←コメント解除(ssl有効)

ssl_cert = </etc/pki/dovecot/certs/dovecot.pem
↓
ssl_cert = </etc/letsencrypt/live/miracle-server.com/mail.crt ←変更(mail.crtの保存場所)

ssl_key = </etc/pki/dovecot/private/dovecot.pem
↓
ssl_key = </etc/letsencrypt/live/miracle-server.com/server.key ←変更(server.keyの保存場所)
Dovecot再起動
[root@centos ~]# systemctl restart dovecot
ブラウザで自己証明書インポート (http://www.ドメイン名/mail.der にアクセス)

1.「開く」をクリック。

2.「証明書のインストール」をクリック。

3.「次へ」をクリック

4.「証明書をすべて次のストアに配置する」にチェックを入れて「参照」をクリック。

5.「信頼されたルート証明機関」を選択して「OK」をクリック。

6.「次へ」をクリック

7.「完了」をクリック

8.「はい」をクリック

9.「OK」をクリック

10.「OK」をクリック
Outlook Express設定 (POPの場合)

1.上部メニューから「ツール」>「アカウント」をクリック。

2.アカウントを選択して「プロパティ」をクリック。

3.詳細設定タブを開き
「このサーバーはセキュリティで保護された接続(SSL)が必要(Q)」にチェックを入れる。
「このサーバーはセキュリティで保護された接続(SSL)が必要(C)」にチェックを入れる。
「送信メール(SMTP)」を「465」に変更して「OK」をクリック。

4.「閉じる」をクリック。
Outlook Express設定 (IMAPの場合)

詳細設定タブを開き
「このサーバーはセキュリティで保護された接続(SSL)が必要(Q)」にチェックを入れる。
「このサーバーはセキュリティで保護された接続(SSL)が必要(C)」にチェックを入れる。
「送信メール(SMTP)」を「465」に変更して「OK」をクリック。
外部に公開する場合
プロトコル(TCP)ポート465番(SMTPS)を開放。 プロトコル(TCP)ポート995番(POP3S)を開放。 プロトコル(TCP)ポート993番(IMAPS)を開放。
Home PageTop