Postfix,dovecon,roundcube Cloudflare证书不可信,未知协议(ssl,tls)

我正试图让dovecot / postfix运行encryption。 我创build了这样的证书:

生成自定义自签名证书

对于第6步,我使用了cloudflares Origin证书/私钥(PEM,RSA)

然后我在postfix / main.cf中更新了我的值:

myhostname = mail.domain.tld mydomain = domain.tld myorigin = $myhostname mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain mynetworks_style = subnet [...] smtpd_use_tls=yes smtpd_tls_security_level = may smtpd_tls_auth_only = yes smtpd_tls_key_file = /etc/postfix/tls/device.key smtpd_tls_cert_file = /etc/postfix/tls/device.crt smtp_tls_CAfile = /etc/postfix/tls/rootCA.pem smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache #smtpd_tls_mandatory_protocols = !SSLv2,!SSLv3 #smtpd_tls_exclude_ciphers = aNULL, DES, 3DES, MD5, DES+MD5, RC4, RC4-MD5 #smtpd_tls_protocols=TLSv1 TLSv1.1 TLSv1.2 TLSv1.3 smtpd_tls_mandatory_ciphers = medium smtpd_tls_received_header = yes tls_random_source = dev:/dev/urandom 

命令openssl s_client -connect mail.domain.tld:587 -starttls smtp -CApath /etc/postfix/tls/ returns:

 epth=0 C = DE, ST = [...], L = [...], O = [...], CN = mail.domain.tld verify error:num=20:unable to get local issuer certificate verify return:1 depth=0 C = DE, ST = [...], L = [...], O = [...], CN = mail.domain.tld verify error:num=27:certificate not trusted verify return:1 depth=0 C = DE, ST = [...], L = [...], O = [...], CN = mail.domain.tld verify error:num=21:unable to verify the first certificate verify return:1 Certificate chain 0 s:/C=[...]/ST=[...]/L=[...]O=[...]/CN=mail.domain.tld i:/O=CloudFlare, Inc./OU=CloudFlare Origin CA/CN=CloudFlare Origin Certificate 

我想实现的是SMTP / IMAP的TLSencryption。 这是我的后缀master.cf:

 # # Postfix master process configuration file. For details on the format # of the file, see the master(5) manual page (command: "man 5 master"). # # Do not forget to execute "postfix reload" after editing this file. # # ========================================================================== # service type private unpriv chroot wakeup maxproc command + args # (yes) (yes) (yes) (never) (100) # ========================================================================== smtp inet n - - - - smtpd #smtp inet n - n - 1 postscreen #smtpd pass - - n - - smtpd #dnsblog unix - - n - 0 dnsblog #tlsproxy unix - - n - 0 tlsproxy submission inet n - - - - smtpd # -o syslog_name=postfix/submission -o smtpd_tls_security_level=encrypt # -o smtpd_sasl_auth_enable=yes ## -o smtpd_reject_unlisted_recipient=no ## -o smtpd_client_restrictions=$mua_client_restrictions ## -o smtpd_helo_restrictions=$mua_helo_restrictions ## -o smtpd_sender_restrictions=$mua_sender_restrictions ## -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #smtps inet n - n - - smtpd # -o syslog_name=postfix/smtps # -o smtpd_tls_wrappermode=yes # -o broken_sasl_auth_clients=yes # -o content_filter= # -o smtpd_sasl_auth_enable=yes # -o smtpd_reject_unlisted_recipient=no # -o smtpd_client_restrictions=$mua_client_restrictions # -o smtpd_helo_restrictions=$mua_helo_restrictions # -o smtpd_sender_restrictions=$mua_sender_restrictions # -o smtpd_recipient_restrictions=permit_sasl_authenticated,reject # -o milter_macro_daemon_name=ORIGINATING #628 inet n - n - - qmqpd pickup unix n - n 60 1 pickup cleanup unix n - n - 0 cleanup qmgr unix n - n 300 1 qmgr #qmgr unix n - n 300 1 oqmgr tlsmgr unix - - n 1000? 1 tlsmgr rewrite unix - - n - - trivial-rewrite bounce unix - - n - 0 bounce defer unix - - n - 0 bounce trace unix - - n - 0 bounce verify unix - - n - 1 verify flush unix n - n 1000? 0 flush proxymap unix - - n - - proxymap proxywrite unix - - n - 1 proxymap smtp unix - - n - - smtp relay unix - - n - - smtp # -o smtp_helo_timeout=5 -o smtp_connect_timeout=5 showq unix n - n - - showq error unix - - n - - error retry unix - - n - - error discard unix - - n - - discard local unix - nn - - local virtual unix - nn - - virtual lmtp unix - - n - - lmtp anvil unix - - n - 1 anvil scache unix - - n - 1 scache # # ==================================================================== # Interfaces to non-Postfix software. Be sure to examine the manual # pages of the non-Postfix software to find out what options it wants. # # Many of the following services use the Postfix pipe(8) delivery # agent. See the pipe(8) man page for information about ${recipient} # and other message envelope options. # ==================================================================== # # maildrop. See the Postfix MAILDROP_README file for details. # Also specify in main.cf: maildrop_destination_recipient_limit=1 # #maildrop unix - nn - - pipe # flags=DRhu user=vmail argv=/usr/local/bin/maildrop -d ${recipient} # # ==================================================================== # # Recent Cyrus versions can use the existing "lmtp" master.cf entry. # # Specify in cyrus.conf: # lmtp cmd="lmtpd -a" listen="localhost:lmtp" proto=tcp4 # # Specify in main.cf one or more of the following: # mailbox_transport = lmtp:inet:localhost # virtual_transport = lmtp:inet:localhost # # ==================================================================== # # Cyrus 2.1.5 (Amos Gouaux) # Also specify in main.cf: cyrus_destination_recipient_limit=1 # #cyrus unix - nn - - pipe # user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -r ${sender} -m ${extension} ${user} # # ==================================================================== # # Old example of delivery via Cyrus. # #old-cyrus unix - nn - - pipe # flags=R user=cyrus argv=/usr/lib/cyrus-imapd/deliver -e -m ${extension} ${user} # # ==================================================================== # # See the Postfix UUCP_README file for configuration details. # #uucp unix - nn - - pipe # flags=Fqhu user=uucp argv=uux -r -n -z -a$sender - $nexthop!rmail ($recipient) # # ==================================================================== # # Other external delivery methods. # #ifmail unix - nn - - pipe # flags=F user=ftn argv=/usr/lib/ifmail/ifmail -r $nexthop ($recipient) # #bsmtp unix - nn - - pipe # flags=Fq. user=bsmtp argv=/usr/local/sbin/bsmtp -f $sender $nexthop $recipient # #scalemail-backend unix - nn - 2 pipe # flags=R user=scalemail argv=/usr/lib/scalemail/bin/scalemail-store # ${nexthop} ${user} ${extension} # #mailman unix - nn - - pipe # flags=FR user=list argv=/usr/lib/mailman/bin/postfix-to-mailman.py # ${nexthop} ${user} 

另外, telnet localhost 587输出:

 Trying ::1... Connected to localhost. Escape character is '^]'. 220 mail.domain.tld ESMTP Postfix EHLO localhost 250-mail.domain.tld 250-PIPELINING 250-SIZE 10240000 250-VRFY 250-ETRN 250-STARTTLS 250-ENHANCEDSTATUSCODES 250-8BITMIME 250 DSN STARTTLS 220 2.0.0 Ready to start TLS mail from:<> Connection closed by foreign host. 

和一个/ var / log / maillog片段:

 Sep 21 20:30:01 mail postfix/smtpd[25947]: connect from unknown[127.0.0.1] Sep 21 20:30:01 mail sendmail[25946]: STARTTLS=client, relay=[127.0.0.1], version=TLSv1/SSLv3, verify=FAIL, cipher=ECDHE-RSA-AES256-GCM-SHA384, bits=256/256 Sep 21 20:30:01 mail postfix/smtpd[25947]: 5584C202EBA7: client=unknown[127.0.0.1] Sep 21 20:30:01 mail postfix/cleanup[25950]: 5584C202EBA7: message-id=<[email protected]> Sep 21 20:30:01 mail sendmail[25946]: v8LIU16t025946: to=root, ctladdr=root (0/0), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=138941, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (Ok: queued as 5584C202EBA7) Sep 21 20:30:01 mail postfix/qmgr[24990]: 5584C202EBA7: from=<[email protected]>, size=1539, nrcpt=1 (queue active) Sep 21 20:30:01 mail postfix/smtpd[25947]: disconnect from unknown[127.0.0.1] Sep 21 20:30:01 mail postfix/local[25951]: 5584C202EBA7: to=<[email protected]>, relay=local, delay=0.01, delays=0.01/0.01/0/0, dsn=2.0.0, status=sent (delivered to maildir) Sep 21 20:30:01 mail postfix/qmgr[24990]: 5584C202EBA7: removed Sep 21 20:32:22 mail postfix/smtpd[26364]: connect from unknown[::1] Sep 21 20:32:36 mail postfix/smtpd[26364]: SSL_accept error from unknown[::1]: -1 Sep 21 20:32:36 mail postfix/smtpd[26364]: warning: TLS library problem: 26364:error:140760FC:SSL routines:SSL23_GET_CLIENT_HELLO:unknown protocol:s23_srvr.c:647: Sep 21 20:32:36 mail postfix/smtpd[26364]: lost connection after STARTTLS from unknown[::1] Sep 21 20:32:36 mail postfix/smtpd[26364]: disconnect from unknown[::1] 

我正在寻找小时,目前我无法find解决scheme。 如果这里有人能帮助我,那简直太棒了。

/ E:

也许我应该提到,如果我取消postfix / master.cf中的smtps,结果是完全一样的。

/E²: /etc/hosts

 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 aws.elastic.beanstalk.ip localhost mail.domain.tld 

/E³:

重新创build证书后,我得到了

 Verify return code: 19 (self signed certificate in certificate chain) 

openssl s_client -connect mail.domain.tld:587 -starttls smtp

我仍然有同样的问题。