smtp with sasl & ssl/tls - Linux

Mia avatar
By Mia
at 2019-05-12T10:59

Table of Contents

請教各位大大,因工作需求,smtp需有SASL驗證以及ss/tls加密,於VM環境將一切設定搞
妥之後,先用telnet試試有無問題:
--------------------------------------------------
[root@test-smtp postfix]# telnet localhost 25
Trying ::1...
Connected to localhost.
Escape character is '^]'.
220 smtp1.twcc.ai ESMTP
ehlo localhost
250-smtp1.twcc.ai
250-PIPELINING
250-SIZE 10240000
250-VRFY
250-ETRN
250-STARTTLS
250-AUTH PLAIN LOGIN
250-AUTH=PLAIN LOGIN
250-ENHANCEDSTATUSCODES
250-8BITMIME
250 DSN
starttls
220 2.0.0 Ready to start TLS
quit
quit
Connection closed by foreign host.
--------------------------------------------------
結果顯示都是OK的,但如果此時看maillog,會出現error訊息,此訊息會導致465 port無
作用:
--------------------------------------------------
May 12 10:44:10 test-smtp postfix/smtpd[17030]: connect from localhost[::1]
May 12 10:44:21 test-smtp postfix/smtpd[17030]: SSL_accept error from
localhost[::1]: -1
May 12 10:44:21 test-smtp postfix/smtpd[17030]: warning: TLS library problem:
17030:error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown
protocol:s23_srvr.c:640:
May 12 10:44:21 test-smtp postfix/smtpd[17030]: lost connection after
STARTTLS from localhost[::1]
May 12 10:44:21 test-smtp postfix/smtpd[17030]: disconnect from localhost[::1]
--------------------------------------------------
請問有人遇過這種問題嗎,能否給小弟建議呢,感謝。

我的main.cf:
--------------------------------------------------
[root@test-smtp ~]# postconf -n
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
broken_sasl_auth_clients = yes
command_directory = /usr/sbin
config_directory = /etc/postfix
daemon_directory = /usr/libexec/postfix
data_directory = /var/lib/postfix
debug_peer_level = 2
debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd
$daemon_directory/$process_name $process_id & sleep 5
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = twcc.ai
myhostname = smtp1.twcc.ai
mynetworks = 192.168.10.0/24, 127.0.0.0/8
mynetworks_style = subnet
myorigin = $myhostname
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
relay_domains = $mydestination
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_tls_mandatory_protocols = !SSLv2,!SSLv3,!TLSv1
smtp_tls_note_starttls_offer = yes
smtp_tls_protocols = !SSLv2,!SSLv3,!TLSv1
smtp_use_tls = yes
smtpd_banner = $myhostname ESMTP
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated,
reject_unknown_sender_domain, reject_unknown_recipient_domain,
reject_unauth_destination, reject_rbl_client cbl.abuseat.org,
reject_rbl_client bl.spamcop.net, reject_rbl_client cblless.anti-spam.org.cn,
reject_rbl_client sbl-xbl.spamhaus.org, check_policy_service
unix:/var/spool/postfix/postgrey/socket
smtpd_sasl_auth_enable = yes
smtpd_sasl_security_options = noanonymous
smtpd_tls_CAfile = /etc/postfix/rootca.crt
smtpd_tls_cert_file = /etc/postfix/smtp1.twcc.ai.crt
smtpd_tls_key_file = /etc/postfix/smtp1.twcc.ai.key
smtpd_tls_loglevel = 1
smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3,!TLSv1
smtpd_tls_protocols = !SSLv2,!SSLv3,!TLSv1
smtpd_tls_received_header = yes
smtpd_tls_session_cache_timeout = 3600s
smtpd_use_tls = yes
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
--------------------------------------------------

我的master.cf僅修改一小部分:
--------------------------------------------------
smtps inet n - n - - smtpd
-o syslog_name=postfix/smtps
-o smtpd_tls_wrappermode=yes
--------------------------------------------------

firewall及selinux已關閉。

--
Tags: Linux

All Comments

Rosalind avatar
By Rosalind
at 2019-05-15T18:21
你telnet 25 port 然後問465?
Lydia avatar
By Lydia
at 2019-05-18T09:12
重點是telnet之後的starttls指令,以及/var/log/maillog
Eartha avatar
By Eartha
at 2019-05-21T06:33
我的問題點是在於憑證問題,不是哪一port的問題
Bennie avatar
By Bennie
at 2019-05-24T08:08
而且telnet不支援ssl
Agatha avatar
By Agatha
at 2019-05-26T12:30
telnet不支援ssl,所以無法telnet 465port
Selena avatar
By Selena
at 2019-05-27T19:14
smtpd_tls_wrappermode=yes 是SMTPs 用的
starttls 不需要設定這個
Hedwig avatar
By Hedwig
at 2019-05-30T04:52
如果你要用 starttls 而不是 TLS 的話可以參考這裡
https://wiki.archlinux.org/index.php/Postfix#TLS
Quintina avatar
By Quintina
at 2019-05-30T16:57
然後 starttls 用的是 587 ,SMTPs 才是465
Jake avatar
By Jake
at 2019-06-03T14:21
你要嘛一開始25或587,要嘛465,應該是不能跳過去
Lydia avatar
By Lydia
at 2019-06-07T16:38
感謝大大,我馬上來試試

Red Hat Enterprise Linux 8.0 正式發佈

Lily avatar
By Lily
at 2019-05-08T22:50
https://openingsource.org/6629/ Red Hat Enterprise Linux 8.0 正式發佈 Red Hat Enterprise Linux(常縮寫作RHEL)是一個由Red Hat (紅帽)公司開發的面向 商業市場的發行版,以出色的穩定性著稱。其基於Fedora ...

Ubuntu 16.04.5 安裝TPM問題

Charlotte avatar
By Charlotte
at 2019-05-07T23:50
※ 引述《wwfrock14 (九份甩尾哥)》之銘言: : 求助各位大神 : 請問Ubuntu 16.04.5 預設TPM 是disabled嗎? : 如果是的話該怎麼enabled 並查詢TPM資訊呢? : 網路上找了好多方法試都不能 : TPM是 2.0的 : 謝謝各位 先看看BIOS或是UEFI有沒有 ...

為何更新kernel5.1後,網路不能動,要更

Wallis avatar
By Wallis
at 2019-05-07T21:32
我用的是linux mint 19.1 mate 為何用ukuu更新kernel5.1後 網路不能動 要更改驅動程式管理員 原本bcmwl-kernel-source 要改成不使用此裝置 無線網卡才能work 並顯示無專有驅動程式使用中 這兩個選項有什麼差別 對了筆電是dell Inspi ...

如何遠端切換系統

Doris avatar
By Doris
at 2019-05-04T15:24
各位大大日安, 如題,不才想請教如何遠端切換系統。 不才希望在一台電腦中,灌win10和linux雙系統。 平常應該只會使用linux,但是有時候會有一些需要使用win10, 例如:使用AI或PS繪圖,使用ppt或者word進行文書處理 不才知道這些功能在linux都有替代用的,譬如inkscap ...

mint安裝發生"無法建立檔案系統"錯誤

Quintina avatar
By Quintina
at 2019-05-04T11:27
基本上如果沒什麼特別需求 而我ssd有256G 我會把246G切成ext4掛載在/上 剩下的直接配給swap 這樣灌是最省事的方法囉 - ...