harumaki.net

インフラ屋の覚書や、ラーメン食べある記とか。

GNU/Linux infra MAIL network postfix サーバー

postfix SMTP-auth + TLSの実装

投稿日:2004年12月28日

Last Updated on 2022年3月13日 by かんりにん

[pukiwiki]

&topicpath;
 
**▼smtp-auth + TLSの実装 [#j312771a]

 別項で記載した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)ソースのダウンロードと展開 [#t6f70922]

[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へパッチをあて、再コンパイル [#u7157fcc]

[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インストール [#u0b4cefc]   インストール時のオプションが長いので注意。   ※自分のインストール環境を確認しておくこと。 [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の作成 [#u8e8c58b] ▼/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対応ディレクティブを追記。 [#w621b9aa] [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を再起動 [#wbd9e0ef] [root@example postfix]# postfix reload postfix/postfix-script: refreshing the Postfix mail system [root@example postfix]# ***7)動作確認 [#a221c7cc] ▼ポート接続テスト [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!から配信テストを行う。  ポートは指定していないのでメーラー側でのポートの変更は不要。   [/pukiwiki]

-GNU/Linux, infra, MAIL, network, postfix, サーバー
-,

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


関連記事

no image

[メモ]FreeBSDでsendmail→postfixへの切り替え

[pukiwiki] FreeBSDでのsendmail→postfix切り替えの作業ログ。 お客さんの会社で、長らく管理人不在のまま使用していたFreeBSDのWebサーバーでハードウェア障害が起き …

no image

courier-mta+phpcourier

[pukiwiki] #topicpath #contents 編集日:2006/03/14 *courier-mta+phpcourier [#w0ec6df1] courier-mta。 MySQ …

no image

lsyncdのエラー修正(監視対象ファイル数の上限値変更)

lsyncdでのバックアップファイルの同期がうまくいってないな~、と思って調べたら、カーネルパラメータ”max_user_watches”の上限値を超えたためlsyncdのプロ …

no image

ただのメモ:cron実行内容をloggerを使ってログファイルに書き出す

crontabでジョブを実行する際、標準出力やスクリプト内にechoで出力した内容を パイプにてloggerコマンドを使って/var/log/messagesへ書き出す。 オプション”-t …

no image

USB接続のHDDをmke2fsでext3にフォーマットしたときのメッセージを確認(tune2fs )

CentOS5.8にて、USB接続の外付けHDDをext3にてフォーマットした際 “ファイルシステムは29回マウントされるか、または180日経過するか、どちらか先に来たら自動でチェックされ …