LinuxでSMTPサーバーを使用してエラーなしでメールを送信する方法

LinuxでSMTPサーバーを使用してエラーなしでメールを送信する方法

SMTPサーバー経由でメールを送信しようとしています。/etc/mail.rcファイルを設定します。

set bsdcompat
set smtp=smtps://smtp.gmail.com:465
set smtp-auth=login
set [email protected]
set smtp-auth-password=password
set ssl-verify=ignore
set nss-config-dir=/etc/pki/nssdb/

これでメールを送信できますが、次のエラーが発生します。

Error in certificate: Peer's certificate issuer is not recognized.

私のnssdbには次のエントリがあります。

certutil -L -d /etc/pki/nssdb

Certificate Nickname Trust Attributes 
                     SSL,S/MIME,JAR/XPI

誰でもこの問題を解決する方法を提案できますか? Googleで検索しましたが、正しい解決策が得られませんでした。

ベストアンサー1

出力によると、certutil -L -d /etc/pki/nssdbnssdbは空です!

openssl s_client -showcerts -connect smtp.gmail.com:465 </dev/nullメールサーバー証明書の公開部分とそれが提供できる発行者証明書をダンプできます。出力内容はかなり長いですが、まず次の行に注意する必要があります。

Server certificate
subject=/C=US/ST=California/L=Mountain View/O=Google LLC/CN=smtp.gmail.com
issuer=/C=US/O=Google Trust Services/CN=Google Internet Authority G3

そして

Certificate chain
 0 s:/C=US/ST=California/L=Mountain View/O=Google LLC/CN=smtp.gmail.com
   i:/C=US/O=Google Trust Services/CN=Google Internet Authority G3
[...]
 1 s:/C=US/O=Google Trust Services/CN=Google Internet Authority G3
   i:/OU=GlobalSign Root CA - R2/O=GlobalSign/CN=GlobalSign

したがって、サーバー(サーバー証明書セクションとそのセクションの証明書の場合subject=)には、「Google Internet Authority G3」によって発行された証明書があります。順番に証明書を受け取りました。0Certificate chainsmtp.gmail.comGlobalSign Root CA - R2

「globalsign root ca R2」というキーワードをGoogleですばやく検索すると、この証明書が2021年に期限切れになるかなり古い証明書であることがわかります。信じればダウンロードしてくださいここ...しかし、Webブラウザに組み込まれている標準の証明書ストアから「Google Internet Authority G3」証明書のコピーをエクスポートする方が良い考えです。

どの証明書を選択しても、ファイルに存在する場合はすぐに使用できますcertutil -A -d /etc/pki/nssdb -i <certificate file>。 (証明書をPEM形式でエクスポートする場合は、このオプションを追加できます-a。)

おすすめ記事