Last Updated on 2022年3月13日 by かんりにん
▼smtp-auth + TLSの実装 †
別項で記載したUNIXパスワードでのsmtp-auth実装に
暗号化を強化するためpostfixにTLSを追加して再コンパイル。
これでOutlook ExpressのLOGIN認証でもある程度の強度を確保できる。
※smtp-authは(一応)実装済み
【参照サイト】お世話になっています!!
http://www.aln1.net/network/postfix+tls+smtp-auth.html
SMTP Auth + TLSの導入(Postfix2.0編)/パソコンおやじ
http://acorn.zive.net/~oyaji/mail2/smtp-auth-tls.htm
【使用したアプリケーション】
postfix-2.1.5
pfixtls-0.8.18-2.1.3-0.9.7d
openssl-0.9.7d
※opensslはすでにインストール済みなのでここでは説明を割愛します。
【postfix用TLSのダウンロードサイト】
http://www.aet.tu-cottbus.de/personen/jaenicke/postfix_tls/
postfixのバージョンに合わせてpfixtlsのバージョンが決まっている。
使用しているpostfixのバージョンが2.1.5なので
ここからpfixtlsのバージョン0.8.18をダウンロード。
1)ソースのダウンロードと展開 †
[user@example user]$ su - Password: [root@example root]# cd /usr/local/src/ [root@example src]# wget ftp://ftp.aet.tu-cottbus.de/pub/postfix_tls/ pfixtls-0.8.18-2.1.3-0.9.7d.tar.gz [root@example src]# [root@example src]# tar -zxvf pfixtls-0.8.18-2.1.3-0.9.7d.tar.gz
2)postfixへパッチをあて、再コンパイル †
[user@example src]$ cd postfix-2.1.5 [user@example postfix-2.1.5]$ patch -p1 < ../pfixtls-0.8.18-2.1.3- 0.9.7d/pfixtls.diff
3)postfixインストール †
インストール時のオプションが長いので注意。
※自分のインストール環境を確認しておくこと。
[user@example postfix-2.1.5]$ make makefiles CCARGS="-DUSE_SASL_AUTH -DHAS_SSL -I/usr/local/include/sasl -I/usr/include/openssl" AUXLIBS="- L/usr/local/lib -L/ usr/lib -lsasl2 -lssl -lcrypto" [user@example postfix-2.1.5]$ make [user@example postfix-2.1.5]$ su root -c "make upgrade"
4)SSLkeyの作成 †
▼/etc/postfix以下にsslディレクトリを作成
[user@example postfix-2.1.5]$ su [root@example postfix-2.1.5]# cd /etc/postfix/ [root@example postfix]# mkdir ssl [root@example postfix]# cd ssl [root@example ssl]# ls [root@example ssl]# ls -al 合計 8 drwxr-xr-x 2 root root 4096 12 28 14:56 . drwxr-xr-x 3 root root 4096 12 28 14:56 ..
▼SSLkeyの生成
1:秘密鍵の生成
[root@example ssl]# openssl genrsa -out server.key 1024 Generating RSA private key, 1024 bit long modulus ..................++++++ ...++++++ e is 65537 (0x10001) [root@example ssl]# [root@example ssl]# ls server.key [root@example ssl]# ls -al 合計 12 drwxr-xr-x 2 root root 4096 12 28 14:56 . drwxr-xr-x 3 root root 4096 12 28 14:56 .. -rw-r--r-- 1 root root 887 12 28 14:56 server.key [root@example ssl]#
2:自署証明書の生成
[root@example ssl]# openssl req -new -x509 -key server.key -out server.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) [AU]:JP State or Province Name (full name) [Some-State]:Tokyo Locality Name (eg, city) []:Docoka Organization Name (eg, company) [Internet Widgits Pty Ltd]:Example.Inc Organizational Unit Name (eg, section) []:***** Common Name (eg, YOUR name) []:admin Email Address []:admin@example.com [root@example ssl]#
5)main.cfにTLS対応ディレクティブを追記。 †
[root@example postfix]# cp main.cf main.cf.20041228_no_TLS [root@example postfix]# vi main.cf 記述内容は以下のとおり。 main.cfの一番下に追記すればOK。 # 証明書ファイルの置き場所の指定 smtpd_tls_cert_file = /etc/postfix/ssl/server.crt # smtpd_tls_key_file = 秘密鍵ファイルの置き場所の指定 smtpd_tls_key_file = /etc/postfix/ssl/server.key # smtpd_tls_session_cache_database = TLSセッションキャッシュデータベースの指定 #smtpd_tls_session_cache_database = sdbm:/etc/postfix/ssl/smtpd_scache # smtpd_tls_loglevel = TLSのログレベル指定 smtpd_tls_loglevel = 3 # smtpd_use_tls starttlsコマンドの利用の指定 smtpd_use_tls = yes
6)postfixを再起動 †
[root@example postfix]# postfix reload postfix/postfix-script: refreshing the Postfix mail system [root@example postfix]#
7)動作確認 †
▼ポート接続テスト
[root@example postfix]# telnet localhost 25 Trying 127.0.0.1... Connected to localhost. Escape character is '^]'. 220 mail.example.jp ESMTP Postfix ehlo localhost 250-mail.example.jp 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS ←ここの応答があればOK!! 250-AUTH LOGIN PLAIN OTP DIGEST-MD5 CRAM-MD5 250-AUTH=LOGIN PLAIN OTP DIGEST-MD5 CRAM-MD5 250 8BITMIME quit 221 Bye Connection closed by foreign host. [root@example postfix]# [root@example postfix]#
▼メール配信テスト
Outlook Express、Becky!から配信テストを行う。
ポートは指定していないのでメーラー側でのポートの変更は不要。