У меня были проблемы с отправкой почты на мой сервер, и есть признаки ошибок TLS (в основном из журнала почты). Что я пробовал:
openssl s_client -connect ${IP}:465
не работает, но порт 443 работаетnmap ${URL}
показывает порты 25,53,80,110,139,143,443,445,993,995
все открытыnmap ${LOCALIP}
показывает порты 22,25,80,110,143,443,993,995
так же открыто с 465,587
закрыто.telnet ${IP} 25
и бег starttls
(терпит неудачу с 454 4.7.0 TLS not available due to local problem
)/etc/letsencrypt
скопировано)/etc/postfix/*.cf
переместив их в * .cf.bak и переустановив postfixДополнительные замечания:
ansible-hardening
из https://github.com/openstack/ansible-hardening
на сервере.Журналы:
# cat /var/log/maillog
postfix/postfix-script: starting the Postfix mail system
postfix/master: daemon started -- version 2.10.1, configuration /etc/postfix
postfix/smtpd: warning: No server certs available. TLS won't be enabled
postfix/smtpd: connect from unknown[${IP}]
# 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
home_mailbox = Maildir/
html_directory = no
inet_interfaces = all
inet_protocols = all
mail_owner = postfix
mail_spool_directory = /var/spool/mail
mailq_path = /usr/bin/mailq.postfix
manpage_directory = /usr/share/man
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
mydomain = example.com
myhostname = webserver1.example.com
mynetworks = 127.0.0.0/8
myorigin = $mydomain
newaliases_path = /usr/bin/newaliases.postfix
queue_directory = /var/spool/postfix
readme_directory = /usr/share/doc/postfix-2.10.1/README_FILES
sample_directory = /usr/share/doc/postfix-2.10.1/samples
sendmail_path = /usr/sbin/sendmail.postfix
setgid_group = postdrop
smtp_tls_cert_file = /etc/letsencrypt/live/example.com/fullchain.pem
smtp_tls_key_file = /etc/letsencrypt/live/example.com/privkey.pem
smtp_tls_note_starttls_offer = yes
smtp_tls_security_level = may
smtpd_client_restrictions = permit_mynetworks, reject
smtpd_recipient_restrictions = permit_sasl_authenticated,permit_mynetworks,reject_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain =
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_loglevel = 2
smtpd_tls_received_header = yes
smtpd_tls_security_level = may
smtpd_tls_session_cache_timeout = 3600s
tls_random_source = dev:/dev/urandom
unknown_local_recipient_reject_code = 550
# doveconf -n
# 2.2.10: /etc/dovecot/dovecot.conf
# OS: Linux 3.10.0-693.21.1.el7.x86_64 x86_64 CentOS Linux release 7.4.1708 (Core) xfs
auth_mechanisms = plain login
first_valid_uid = 1000
mail_location = maildir:/var/spool/mail/%u
mbox_write_locks = fcntl
namespace inbox {
inbox = yes
location =
mailbox Drafts {
special_use = \Drafts
}
mailbox Junk {
special_use = \Junk
}
mailbox Sent {
special_use = \Sent
}
mailbox "Sent Messages" {
special_use = \Sent
}
mailbox Trash {
special_use = \Trash
}
prefix =
}
passdb {
driver = pam
}
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0666
user = postfix
}
}
ssl = required
ssl_cert = </etc/letsencrypt/live/example.com/fullchain.pem
ssl_key = </etc/letsencrypt/live/example.com/privkey.pem
userdb {
driver = passwd
}
# # Could replace cat/etc/postfix/main.cf with postconf -n
# sudo -u postfix cat $(cat /etc/postfix/main.cf | grep -i smtp_tls_cert_file | cut --delimiter="=" --fields=2)
-----BEGIN CERTIFICATE-----
...key text...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
...key text...
-----END CERTIFICATE-----
# sudo -u postfix cat $(cat /etc/postfix/main.cf | grep -i smtp_tls_key_file | cut --delimiter="=" --fields=2)
-----BEGIN PRIVATE KEY-----
...private key text...
-----END PRIVATE KEY-----
# sealert -a /var/log/audit/audit.log
100% done
found 0 alerts in /var/log/audit/audit.log
Обе команды openssl дают фактически эквивалентные ответы (порт 443 имеет другой ответ и работает).
$ openssl s_client -starttls smtp -connect ${IP}:587
$ openssl s_client -starttls smtp -connect ${IP/URL}:465
CONNECTED(00000003)
140495880024000:error:1408F10B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:252:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 5 bytes and written 176 bytes
Verification: OK
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
SSL-Session:
Protocol : TLSv1.2
Cipher : 0000
Session-ID:
Session-ID-ctx:
Master-Key:
PSK identity: None
PSK identity hint: None
SRP username: None
Start Time: 1520878163
Timeout : 7200 (sec)
Verify return code: 0 (ok)
Extended master secret: no
---
$ telnet ${IP} 25
Trying ${IP}...
Connected to ${IP}.
Escape character is '^]'.
220 webserver1.example.com ESMTP Postfix
ehlo localhost
250-webserver1.example.com
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
454 4.7.0 TLS not available due to local problem
Попробуйте изменить конфигурацию smtp_tls_cert
и smtp_tls_key
вместо этого на следующее:
smtpd_tls_cert_file = /etc/letsencrypt/live/example.com/fullchain.pem
smtpd_tls_key_file = /etc/letsencrypt/live/example.com/privkey.pem
Обратите внимание на d
в smtpd