Dkfilter
2018年2月7日 (水) 00:16時点におけるKusakata.bot (トーク | 投稿記録)による版 (文字列「http://tools.ietf.org/」を「https://tools.ietf.org/」に置換)
DomainKeys は電子メール署名・検証技術です。RFC で公開されており多数のメールサーバーによってサポートされています (yahoo や google など)。
送信者は秘密鍵を使ってメールに署名をして、受信者は DNS から公開鍵を要求して検証を行います。検証によってメールの送信者を確認することができます。詳しくは RFC 4870 を見てください。
インストール
デフォルトでは dkfilter ユーザーとグループを追加する必要があります。追加したくない場合、/etc/conf.d/dkfilter を編集して DKFILTER_USER と DKFILTER_GROUP を書き換えてください。
設定
- 鍵を生成:
$ openssl genpkey -algorithm RSA -pkeyopt rsa_keygen_bits:2048 -out private.key $ openssl rsa -in private.key -pubout -out public.key
/etc/conf.d/dkfilterを編集してください。- セレクタと鍵を記述した DNS レコードを追加 (
/etc/conf.d/dkfilterの DKFILTER_SELECTOR を参照、ランダムな名前を使うこともできます):
server1._domainkey IN TXT "k=rsa; p=MHwwDQYJK ... OprwIDAQAB; t=y"
dkfilter-in.serviceとdkfilter-out.serviceを起動してください。
Postfix の統合
Inbound フィルター
Inbound フィルターはポート 10025 から接続を受け取ってフィルタリングしたデータをポート 10026 から出力します (Inbound フィルターはデータを削除せず、メールに検証結果を追加します)。
/etc/postfix/master.cf に以下を追加:
#
# Before-filter SMTP server. Receive mail from the network and
# pass it to the content filter on localhost port 10025.
#
smtp inet n - n - - smtpd
-o smtpd_proxy_filter=127.0.0.1:10025
-o smtpd_client_connection_count_limit=10
#
# After-filter SMTP server. Receive mail from the content filter on
# localhost port 10026.
#
127.0.0.1:10026 inet n - n - - smtpd
-o smtpd_authorized_xforward_hosts=127.0.0.0/8
-o smtpd_client_restrictions=
-o smtpd_helo_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o smtpd_data_restrictions=
-o mynetworks=127.0.0.0/8
-o receive_override_options=no_unknown_recipient_checks
Outbound フィルター
Outbound フィルターはポート 10027 から接続を受け取って署名済みデータをポート 10028 に出力します。
/etc/postfix/master.cf に以下を追加:
#
# modify the default submission service to specify a content filter
# and restrict it to local clients and SASL authenticated clients only
#
submission inet n - n - - smtpd
-o smtpd_etrn_restrictions=reject
-o smtpd_sasl_auth_enable=yes
-o content_filter=dksign:[127.0.0.1]:10027
-o receive_override_options=no_address_mappings
-o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject
#
# specify the location of the DomainKeys signing filter
#
dksign unix - - n - 10 smtp
-o smtp_send_xforward_command=yes
-o smtp_discard_ehlo_keywords=8bitmime
#
# service for accepting messages FROM the DomainKeys signing filter
#
127.0.0.1:10028 inet n - n - 10 smtpd
-o content_filter=
-o receive_override_options=no_unknown_recipient_checks,no_header_body_checks
-o smtpd_helo_restrictions=
-o smtpd_client_restrictions=
-o smtpd_sender_restrictions=
-o smtpd_recipient_restrictions=permit_mynetworks,reject
-o mynetworks=127.0.0.0/8
-o smtpd_authorized_xforward_hosts=127.0.0.0/8