
像許多升級到 Rails 2.2 的人一樣,我在發送電子郵件時遇到了異常。此版本的 Rails 或更高版本確實需要使用 tls 來傳送電子郵件。生產日誌檔案中的消息顯示:
hostname was not match with the server certificate
我為此做了很多研究和工作,並盡了我所能。我將切片的主機名稱更改為 ohlalaweb.com。如果我在 CL 上運行命令“主機名”,我會得到:
ohlalaweb.com
Postfix 似乎運作正常。我可以毫無問題地從 CL 向我的 gmail、yahoo 和 google apps gmail 帳戶發送電子郵件。這是 cat /etc/postfix/main.cf 的結果
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
# Debian specific: Specifying a file name will cause the first
# line of that file to be used as the name. The Debian default
# is /etc/mailname.
myorigin = /etc/mailname
smmtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
readme_directory = no
# TLS parameters
smtpd_tls_cert_file=/etc/ssl/certs/ohlalaweb.pem
smtpd_tls_key_file=/etc/ssl/certs/ohlalaweb.pem
smtpd_use_tls=yes
# SA created next line to force postfix to use self create certificate
smtpd_tls_auth_only=yes
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
# See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
# information on enabling SSL in the smtp client.
myhostname = ohlalaweb.com
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = localhost.localdomain, localhost
relayhost =
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_size_limit = 0
recipient_delimiter = +
inet_interfaces = all
我已使用 ohlalaweb.com 主機名稱重新產生了 ssl 金鑰。
有什麼想法或建議嗎?
答案1
ohlalaweb.com 是域名,而不是主機名,至少不應該是。主機名稱類似於「mail.ohlalaweb.com」中的「mail」。憑證驗證失敗,因為伺服器名稱與憑證的 CommonName 欄位中的名稱不符。
最簡單的解決方案是更改伺服器的名稱以符合憑證的 CommonName 欄位中的條目。