
私は、Ubuntu で新しい SSL 証明書を使用して、dovecot imap サーバー (バージョン 1.0.10 - 現時点ではアップグレードはオプションではありません) を次のように構成しようとしています。
$ grep ^ssl /etc/dovecot/dovecot.conf
ssl_disable = no
ssl_cert_file = /etc/ssl/certs/mydomain.com.crt.20120904
ssl_key_file = /etc/ssl/private/mydomain.com.key.20120904
$ /etc/init.t/dovecot stop
$ sudo dovecot -p
$ [i enter the ssl password here]
エラーは表示されず、実行するps aux | grep dovecot
と
root 21368 0.0 0.0 12452 688 ? Ss 15:19 0:00 dovecot -p
root 21369 0.0 0.0 71772 2940 ? S 15:19 0:00 dovecot-auth
dovecot 21370 0.0 0.0 14140 1904 ? S 15:19 0:00 pop3-login
dovecot 21371 0.0 0.0 14140 1900 ? S 15:19 0:00 pop3-login
dovecot 21372 0.0 0.0 14140 1904 ? S 15:19 0:00 pop3-login
dovecot 21381 0.0 0.0 14280 2140 ? S 15:19 0:00 imap-login
dovecot 21497 0.0 0.0 14280 2116 ? S 15:29 0:00 imap-login
dovecot 21791 0.0 0.0 14148 1908 ? S 15:48 0:00 imap-login
dovecot 21835 0.0 0.0 14148 1908 ? S 15:53 0:00 imap-login
dovecot 21931 0.0 0.0 14148 1904 ? S 16:00 0:00 imap-login
me 21953 0.0 0.0 5168 944 pts/0 S+ 16:02 0:00 grep --color=auto dovecot
すべて正常に動作しているようです。次に、dovecot サーバーに telnet できるかどうかをテストすると、正常に動作します。
$ telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
* OK Dovecot ready.
しかし、dovecot が SSL 証明書を適切に構成したかどうかをテストすると、失敗するようです。
$ sudo openssl s_client -connect localhost:143 -starttls imap
CONNECTED(00000003)
depth=0 /description=xxxxxxxxxxxxxxxxx/C=AU/ST=xxxxxxxx/L=xxxx/O=xxxxxx/CN=*.mydomain.com/[email protected]
verify error:num=20:unable to get local issuer certificate
verify return:1
depth=0 /description=xxxxxxxxxxx/C=AU/ST=xxxxxx/L=xxxx/O=xxxx/CN=*.mydomain.com/[email protected]
verify error:num=27:certificate not trusted
verify return:1
depth=0 /description=xxxxxxxx/C=AU/ST=xxxxxxxxxx/L=xxxx/O=xxxxx/CN=*.mydomain.com/[email protected]
verify error:num=21:unable to verify the first certificate
verify return:1
---
Certificate chain
0 s:/description=xxxxxxxxxxxx/C=AU/ST=xxxxxxxxxx/L=xxxxxxxx/O=xxxxxxx/CN=*.mydomain.com/[email protected]
i:/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA
---
Server certificate
-----BEGIN CERTIFICATE-----
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxxxx
.
.
.
xxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx==
-----END CERTIFICATE-----
subject=/description=xxxxxxxxxx/C=AU/ST=xxxxxxxxx/L=xxxxxxx/O=xxxxxx/CN=*.mydomain.com/[email protected]
issuer=/C=IL/O=StartCom Ltd./OU=Secure Digital Certificate Signing/CN=StartCom Class 2 Primary Intermediate Server CA
---
No client certificate CA names sent
---
SSL handshake has read 2831 bytes and written 342 bytes
---
New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 2048 bit
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1
Cipher : DHE-RSA-AES256-SHA
Session-ID: xxxxxxxxxxxxxxxxxxxx
Session-ID-ctx:
Master-Key: xxxxxxxxxxxxxxxxxx
Key-Arg : None
Start Time: 1351661960
Timeout : 300 (sec)
Verify return code: 21 (unable to verify the first certificate)
---
. OK Capability completed.
少なくとも、これは失敗だと思いますか?
答え1
問題はdovecotではなくopensslにあります。
があるバグopenssl では、デフォルトの CApath の検索が停止されるため、コマンド ラインに追加して、ルート CA 証明書のリストがどこにあるかを伝える必要があります-CApath
。たとえば、次のようになります。
sudo openssl s_client -connect localhost:143 -starttls imap -CApath /dev/null
証明書フォルダにまだ入力していない場合、コンピュータの知識がある場合は、次の手順に従ってください。このチュートリアルMozilla から certdata.txt をダウンロードし、必要な PEM ファイルとシンボリックリンクを生成します。/bin にアクセスできない場合はスクリプトを変更する必要があり、シンボリックリンク ln -s ca-bundle.crt cert.pem を作成する必要があります。
(/dev/null を指定すると、openssl は openssl ディレクトリ内の cert.pem のデフォルト パスを使用するようになります。openssl ディレクトリの場所を確認するには、と入力しますopenssl version -d
)。
StartSSL を使用している場合、証明書と dovecot の中間証明書 (StartCom Class 2 Primary Intermediate Server CA) を連結する必要があるかもしれません。無料の証明書は StartCom Class 1 Primary Intermediate Server CA を使用します。
答え2
verbose_ssl = yes
追加のログ出力を生成するには、dovecot 構成で使用することができます。
私の設定 (dovecot 2.0) では、次のステートメントを使用します。
ssl_cert = </etc/ssl/certs/mydomain.com.crt.20120904
ssl_key = </etc/ssl/private/mydomain.com.key.20120904
答え3
古い質問 - 新しい問題 (今回は Letsencrypt 証明書):
"検証リターンコード: 21 (最初の証明書を検証できません)「
(中間証明書(チェーン)が見つからない/検証に使用されていないことを意味します)
過去 24 時間にわたる試行錯誤の末に私が見つけた解決策は次のとおりです。
まず、テストに使用したものを前置きさせてください。
別のメール サーバー (Ubuntu 18.xx) に Dovecot があり、local.conf
使用されているドメイン/証明書以外は同じ Dovecot 設定になっています。どちらも Letsencrypt 証明書を使用しており、どちらも昨日更新されました。
Ubuntu 18のDovecot(バージョン2.2.33.2)は完璧に動作します。
使用してもエラーコードは発生しません。openssl s_client電子メール ポート :993/IMAP または :995/POP をテストします。
しかし、別のマシン(エラーが表示されているマシン)では、次を使用します。
OS: Ubuntu 20.04.2
Dovecot (Ubuntu のデフォルト/リポジトリ バージョン): 2.3.7.2 (3c910f64b)
OpenSSL (Ubuntu のデフォルト/リポジトリ バージョン):1.1.1f 31 Mar 2020
このエラーに気付いたのは、Android スマートフォン (Google/Gmail のデフォルトのメール アプリ) にメール アカウントを追加することについて顧客から苦情があったときでした。
「証明書は信頼できません。」
Web または SMTP に証明書を使用すると、openssl テストは正常に動作し、検証されます。
このことから、問題は Ubuntu 20 上の Dovecot にあると考えられます。
Thunderbird や Outlook などの他の電子メール クライアントも正常に動作します。
私はすぐに「openssl s_client」でテストすることに決めましたが、最終的にエラーがここに来ました。
私の設定は、壊れた dovecot マシンと動作している dovecot マシンの両方で次のようになりました。
ssl_ca = </etc/letsencrypt/live/{CertName}/fullchain.pem
ssl_cert = </etc/letsencrypt/live/{CertName}/cert.pem
ssl_key = </etc/letsencrypt/live/{CertName}/privkey.pem
どのソフトウェアがエラーの原因であるかは特定していませんが、エラーは解消しました。Android フォンは証明書を完全に信頼するようになりました。エラーの原因は、証明書チェーン/CA の検証不足である可能性が高いことはわかっていました。
解決策/TL;DR:
使用フルチェーン.pem証明書エントリ ( ssl_cert =
) として。LE 証明書とチェーンの両方が含まれます。
SSL 用の Dovecot 構成は次のようになります (当然のことながら、{CertName} を独自のものに置き換えてください)。
ssl_ca = </etc/letsencrypt/live/{CertName}/chain.pem (or 'fullchain' should work)
ssl_cert = </etc/letsencrypt/live/{CertName}/fullchain.pem
ssl_key = </etc/letsencrypt/live/{CertName}/privkey.pem
テスト中にエラーが表示されなくなるはずです。
Verify return code: 0 (ok)
エラーが表示されていないマシン (Ubuntu 18) では何も変更する必要がなかったので、変更しませんでした。
更新:
現在 Ubuntu 20 リポジトリ/apt で使用されている Dovecot が影響を受けています。
バグ参照:https://dovecot.org/pipermail/dovecot/2021-April/121884.html