debian 9 中的 exim4 收到了 TLS 致命警報

debian 9 中的 exim4 收到了 TLS 致命警報

我正在嘗試配置我的伺服器來發送郵件,但每次嘗試發送郵件時都會收到“TLS 致命警報”錯誤。

我已按照中所示的步驟進行操作這個帖子與我的問題相關,試圖克服該問題,但它最終給了我我所描述的錯誤:

apt install gnutls-bin
cd /etc/exim4/
certtool --generate-privkey --outfile exim.key
certtool --generate-request --load-privkey exim.key --outfile exim.csr
  • 通用名稱:gestiondecorreos.es

  • 其餘的我留空(輸入)

  • 網址:http://www.cacert.org/

  • 登入 CACert => 按一下「伺服器憑證」=> 新建

  • 它會要求您貼上證書請求:我貼上 exim.csr 檔案的內容。

  • CACert 將要求您確認主機名稱。

  • 之後,它將在生成的網頁中顯示證書。將憑證放入名為 exim.crt 的新檔案中

    cd /etc/exim4/ chgrp Debian-exim exim.key chmod g+r exim.key vim /etc/exim4/conf.d/main/000_local (新檔案)

  • 並在裡面插入:

    MAIN_LOG_SELECTOR=+tls_cipher +tls_peerdn MAIN_TLS_ENABLE=t

    update-exim4.conf /etc/init.d/exim4 restart

我嘗試透過 tls 連接到我的郵件伺服器:

gnutls-cli -s -p 587 gestiondecorreos.es
ehlo gestiondecorreos.es
starttls
^D (ctr+d)
  • 錯誤結果:

*** Starting TLS handshake
- Certificate type: X.509
- Got a certificate list of 1 certificates.
- Certificate[0] info:
 - subject `EMAIL=eguz*****@gmail.com,CN=server.example.com,OU=IT,O=Vesta Control Panel,L=San Francisco,ST=California,C=US', issuer `EMAIL=eguz*****@gmail.com,CN=server.example.com,OU=IT,O=Vesta Control Panel,L=San Francisco,ST=California,C=US', serial 0x0086e738bec1714309, RSA key 4096 bits, signed using RSA-SHA256, activated `2020-02-04 15:42:00 UTC', expires `2021-02-03 15:42:00 UTC', key-ID `sha256:6095e39dc286060d74d300f494814744d803ad2f5c55587ca38a2d7ed2b58194'
   Public Key ID:
      sha1:5f4b******************
      sha256:6095****************
   Public key's random art:
      +--[ RSA 4096]----+
      |        ..o    .o|
      |       .   o   +.|
      *******************
      |             .oo.|
      +-----------------+

- Status: The certificate is NOT trusted. The certificate issuer is unknown. The name in the certificate does not match the expected.
*** PKI verification of server certificate failed...
*** Fatal error: Error in the certificate.
*** Handshake has failed

我不知道為什麼會出現 CN=server.example.com 這樣的主題。

/var/log/exim4/mainlog 檔案表示:

TLS error on connection from lixxxxxx.members.linode.com ([127.0.0.1]) [xxxxxxxxxxx] (gnutls_handshake): A TLS fatal alert has been received.

在我的 linode-vps 中,主網域是 gestiondecorreos.es,orbelanet.com 是我正在執行 smtp 測試的另一個網域。

先致謝!米克爾

答案1

嘗試解決方案

  • 更改主機名稱(在 Vestacp 中):(server => gestiondecorreos.es,我在 server 中的主域):

    /usr/local/vesta/bin/v-change-sys-hostname gestiondecorreos.es

  • 在 gestiondecorreos.es 中安裝 LetsEncrypt:

/usr/local/vesta/bin/v-add-letsencrypt-domain 'admin' gestiondecorreos.es '' 'yes'

  • 在 Vesta、Exim 和 Dovecot 中套用上一步驟安裝的 ssl 憑證:

/usr/local/vesta/bin/v-update-host-certificate admin gestiondecorreos.es

  • 在 /usr/local/vesta/conf/vesta.conf 中新增「update_hostname_ssl='yes'」:

    echo "UPDATE_HOSTNAME_SSL='yes'" >> /usr/local/vesta/conf/vesta.conf

這將告訴 Vesta 每次更新 SSL 時將 SSL 更新到 Vesta、Exim 和 dovecot 守護程序。這會自動發生

解決方案

  • 當按照前面的步驟重新建立exim.key和檔案並執行 tls 郵件服務測試時,exim.csr這次不會出現錯誤,一切正常。exim.crtgnutls-cli -s -p 587 gestiondecorreos.es

  • 但當嘗試傳送新電子郵件時,出現以下錯誤:

    H=lixxxxxxxx.linode.com ([127.0.0.1]) [172.xxxxxxxxxx] X=TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128 CV=no rejected MAIL <xxxx@xxxxxxxx>: Helo name contains a ip address (HELO was [127.0.0.1]) and not is valid

  • 解決方案是我繼續禁用 /etc/exim4/exim4.conf 中的以下行:

\# deny condition = ${if eq{$sender_helo_name}{}}
\# message = HELO required before MAIL

\# drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
\# condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
\# condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
\# delay = 45s

\# drop condition = ${if isip{$sender_helo_name}}
\# message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
  • 重新啟動 exim4:

    service exim4 restart

現在我可以毫無問題地發送電子郵件了!

相關內容