StartSSL証明書のインストール-Postfix / Dovecot / Nginx

前のトピックで、 SSL証明書を無料で取得できるサービスについて説明しました。 そして、継続するかのように、私はそれらを1つまたは別のソフトウェアにインストールする方法を説明することにしました。

次のソフトウェアを確認します。





上記のすべてがCentOS 5.5にインストールされます。

後置

接尾辞で最も苦しんだ。 ドキュメンテーション、たくさんの例などがあるように思えますが、すべてがシンプルである必要がありますが、いや、ドキュメンテーションを読み直している間にたくさんのオプションを試したので、すべてが機能し始めるまで多くの時間を殺しました。

準備する
ドメインの秘密鍵と証明書をすでに持っていることがわかります。

mail.example.com.key

mail.example.com.crt






また、必要なクラスの中間CA証明書を含むファイルをダウンロードする必要があります。

ここで見つけることができます

無料の証明書の場合、これはsub.class1.server.ca.pemです。

この例では、パスフレーズなしで秘密鍵を使用します。

したがって、3つのファイルがあります。

mail.example.com.key

mail.example.com.crt

sub.class1.server.ca.pem






接尾辞を食べるファイルを作成する

cat mail.example.com.key mail.example.com.crt sub.class1.server.ca.pem > mail.example.com.pem





必要に応じて結果のファイルをコピーし、/ etc / pki / postfix /に私のものを入れます

もちろん、キーはファイル内にあるため、所有者と権限を設定することを忘れないでください。



/etc/postfix/main.cfに追加:

smtpd_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

smtpd_tls_cert_file = /etc/pki/postfix/mail.example.com.pem #

smtpd_tls_key_file = /etc/pki/postfix/mail.example.com.pem #

smtpd_tls_session_cache_database = btree:/var/lib/postfix/smtpd_tls_session_cache

smtpd_use_tls = yes



smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt

smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache

smtpd_tls_security_level = may



smtpd_tls_received_header = yes

smtpd_tls_loglevel = 1

smtpd_tls_auth_only = no

tls_random_source = dev:/dev/urandom







各パラメーターの意味とその原因は、Postifxのドキュメントに記載されています

すべてが正常であることを確認するには、次のコマンドを使用できます。

openssl s_client -starttls smtp -showcerts -connect localhost:25





結果は次のようなものを返すはずです。

SSL handshake has read 4760 bytes and written 354 bytes

---

New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA

Server public key is 4096 bit

Secure Renegotiation IS supported

Compression: NONE

Expansion: NONE

SSL-Session:

Protocol : TLSv1

Cipher : DHE-RSA-AES256-SHA

Session-ID: 418AA0ED7BA85B2B9301FA127D05DCAFABCEDC192101A6E75DD872FA3E528366

Session-ID-ctx:

Master-Key: 498FB41D5810A9768710936351DC92169B6D7DEFAHTEDBDUO60DE9349DA7EB5536F975A8BC4AF190466B637CC129A93E

Key-Arg : None

Krb5 Principal: None

Start Time: 1287331961

Timeout : 300 (sec)

Verify return code: 0 (ok)

---

250 DSN







/etc/postfix/master.cfで、次の行のコメントを解除します。

smtps inet n - n - - smtpd

-o smtpd_tls_wrappermode=yes

-o smtpd_sasl_auth_enable=yes








接尾辞はこれですべてです。



ドコット

dovekotを使用すると、すべてが非常にシンプルになり、すべてが初めて機能しました。

準備する
既に3つのファイルがあります

mail.example.com.key

mail.example.com.crt

sub.class1.server.ca.pem






キーをコピーし、dovecotを食べる証明書を作成します

cp mail.example.com.key /etc/pki/dovecot/private/

cat mail.example.com.crt sub.class1.server.ca.pem > /etc/pki/dovecot/certs/mail.example.com.pem







dovecot.confでは、次のように記述する必要があります。

ssl_cert_file = /etc/pki/dovecot/certs/mail.example.com.pem

ssl_key_file = /etc/pki/dovecot/private/mail.example.com.key






そしてもちろんSSLを有効にします

ssl_listen = *

ssl = yes






また、個人的に必要なプロトコルのリストに追加します。

protocols = pop3 pop3s imap imaps





UPD:異なるサブドメイン(imap.example.comとpop.example.comなど)でIMAPとPOPを提供する必要がある場合は、上記のように各サブドメインの証明書を準備する必要があります

そして、dovecot.confに以下の変更を加えます

protocol imap {

listen = 192.0.2.1:143

ssl_listen = 192.0.2.1:993

ssl_cert_file = /etc/pki/dovecot/certs/imap.example.com.pem

ssl_key_file = /etc/pki/dovecot/private/imap.example.com.key

}

protocol pop3 {

listen = 192.0.2.1:110

ssl_listen = 192.0.2.1:995

ssl_cert_file = /etc/pki/dovecot/certs/pop.example.com.pem

ssl_key_file = /etc/pki/dovecot/private/pop.example.com.key

}








この記事への追加についてAndrey_Zentavrに感謝します。



Nginx

彼も、すべてが非常に簡単であり、一般的に手順はdovecotと変わりません

準備する
既に3つのファイルがあります

mail.example.com.key

mail.example.com.crt

sub.class1.server.ca.pem






キーをコピーし、nginxが食べる証明書を作成します

cp mail.example.com.key /etc/pki/nginx/private/

cat mail.example.com.crt sub.class1.server.ca.pem > /etc/pki/nginx/certs/mail.example.com.pem







nginxホストの構成は次のようになります。

server {

listen 443;

server_name mail.example.com;

ssl on;

ssl_certificate /etc/pki/nginx/certs/mail.example.com.pem;

ssl_certificate_key /etc/pki/nginx/private/mail.example.com.key;



ssl_session_timeout 5m;



ssl_protocols SSLv2 SSLv3 TLSv1;

ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

ssl_prefer_server_ciphers on;



location / {

root /srv/www/htdocs/;

index index.html index.htm;

}

}










それだけです。このトピックが誰かに役立つと思います。



UPD2:貴重な修正をしてくれたrojerに感謝します。



All Articles