{"id":110,"date":"2017-03-06T09:35:03","date_gmt":"2017-03-06T09:35:03","guid":{"rendered":"http:\/\/www.hestben.se\/HestbenTechnical\/?p=110"},"modified":"2017-03-06T09:35:03","modified_gmt":"2017-03-06T09:35:03","slug":"find-out-if-tls-is-used-when-sending-mail","status":"publish","type":"post","link":"https:\/\/www.hestben.se\/HestbenTechnical\/?p=110","title":{"rendered":"Find out if TLS is used when sending mail"},"content":{"rendered":"<p>So, I have an old installation of Debian, with postfix, and I don&#8217;t remember how I set it up. I should check that it is using sane settings and really using encryption for the transport of mails. This is on my Debian Jessie 8.7 server.<br \/>\nFirst, I wanted to see what version of postfix I am using.<br \/>\nIssuing <code>postcond -d | grep mail_version<\/code> yields the version <code>2.11.3.<\/code>.<br \/>\nSo, according to the answers in this <a href=\"http:\/\/serverfault.com\/questions\/120123\/forcing-smtp-outgoing-mail-encryption-on-postfix#120145\">question<\/a>, I should use the newer configuration options <code>smtp_tls_security_level<\/code>.<br \/>\nIn the configuration that existed on the server, I didn&#8217;t have anything about smtp, only for smtpd (incoming mail). From logs obtained when running <code>smtp<\/code> with the options <code>-v -v<\/code> (Change the settings in <code>\/etc\/postfix\/master.cf<\/code> and restart postfix):<br \/>\n<code>Mar  2 16:30:17 galerkin postfix\/smtp[15196]: > mail.tele2.se[212.247.156.1]:587: EHLO galerkin.hestben.dyndns-ip.com<br \/>\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-mailfe09.swip.net host name is unknown galerkin.hestben.dyndns-ip.com\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-DSN\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-SIZE 314572800\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-STARTTLS\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-AUTH LOGIN PLAIN\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-ETRN\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-TURN\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-ATRN\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-NO-SOLICITING\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-8BITMIME\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-HELP\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250-PIPELINING\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: < mail.tele2.se[212.247.156.1]:587: 250 EHLO<\/code><br \/>\nThen, it looks like it creates a TCP buffer with the login credentials, and then issues AUTH LOGIN:<br \/>\n<code>Mar  2 16:30:17 galerkin postfix\/smtp[15196]: smtp_sasl_authenticate: mail.tele2.se[212.247.156.1]:587: SASL mechanisms LOGIN PLAIN<br \/>\nMar  2 16:30:17 galerkin postfix\/smtp[15196]: > mail.tele2.se[212.247.156.1]:587: AUTH LOGIN<\/code><br \/>\nI.e. no encryption used, so I added <code>smtp_tls_security_level=may<\/code> to main.cf (you can also use <code>postconf -e \"smtp_tls_security_level=may\"<\/code>)<br \/>\nThen reloaded postfix with<br \/>\n<code>postfix reload<\/code><br \/>\nYou can then verify that the setting is set with<br \/>\n<code>postconf | grep smtp_tls_security_level<\/code>.<br \/>\nNow the mail.log looks like:<br \/>\n<code>Mar  3 15:11:41 galerkin postfix\/pickup[22696]: 98D91232032: uid=0 from=<root><br \/>\nMar  3 15:11:41 galerkin postfix\/cleanup[22702]: 98D91232032: message-id=<20170303141141.98D91232032@galerkin.hestben.dyndns-ip.com><br \/>\nMar  3 15:11:41 galerkin postfix\/qmgr[22697]: 98D91232032: from=<root@hestben.dyndns-ip.com>, size=359, nrcpt=1 (queue active)<br \/>\nMar  3 15:11:42 galerkin postfix\/smtp[22704]: Untrusted TLS connection established to mail.tele2.se[212.247.156.1]:587: TLSv1 with cipher AES256-SHA (256\/256 bits)<br \/>\nMar  3 15:11:43 galerkin postfix\/smtp[22704]: 98D91232032: to=<destination>, relay=mail.tele2.se[212.247.156.1]:587, delay=2.2, delays=0.31\/0.3\/0.5\/1.1, dsn=2.0.0, status=sent (250 549908680 mailfe03 Message accepted for delivery)<br \/>\nMar  3 15:11:43 galerkin postfix\/qmgr[22697]: 98D91232032: removed<\/code><br \/>\nSo, now you could hope tele2 would change to a better cipher with perfect forward secrecy (such as ECDHE-RSA-AES256-GCM-SHA384). Reading through the reference below about <a href=\"http:\/\/www.postfix.org\/FORWARD_SECRECY_README.html\">postfix forward secrecy<\/a>, it also looks like the server does not support anonymous cipher suites =(.<\/p>\n<p>Now, check incoming mail. The setting for the incoming mail which is called <code>smtpd_tls_security_level<\/code>. I had previously used <code>smtpd_use_tls=yes<\/code> so I changed to the newer setting. I sent a mail to my server (there is only a dyndns-ip configured for it, I use an external email provider for my hestben.se-domain).<br \/>\nThe log from that looks like this:<br \/>\n<code>Mar  3 15:29:33 galerkin postfix\/smtpd[22788]: connect from mx.kolabnow.com[95.128.36.1]<br \/>\nMar  3 15:29:33 galerkin postfix\/smtpd[22788]: Anonymous TLS connection established from mx.kolabnow.com[95.128.36.1]: TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256\/256 bits)<br \/>\nMar  3 15:29:33 galerkin postfix\/smtpd[22788]: A0EC523202F: client=mx.kolabnow.com[95.128.36.1]<br \/>\nMar  3 15:29:33 galerkin postfix\/cleanup[22793]: A0EC523202F: message-id=<20170303142924.GB4898@debian.hestben.dyndns-ip.com><\/code><br \/>\nSuper, it is even using a good cipher.<\/p>\n<p>References : <a href=\"http:\/\/www.postfix.org\/FORWARD_SECRECY_README.html\">postfix forward secrecy<\/a>, <a href=\"http:\/\/www.postfix.org\/TLS_README.html\">postfix tls readme<\/a>, <a href=\"http:\/\/www.postfix.org\/postconf.5.html\">postfix main.cf format<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, I have an old installation of Debian, with postfix, and I don&#8217;t remember how I set it up. I should check that it is using sane settings and really using encryption for the transport of mails. This is on my Debian Jessie 8.7 server. First, I wanted to see what version of postfix I &hellip; <a href=\"https:\/\/www.hestben.se\/HestbenTechnical\/?p=110\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Find out if TLS is used when sending mail&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=\/wp\/v2\/posts\/110"}],"collection":[{"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=110"}],"version-history":[{"count":7,"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=\/wp\/v2\/posts\/110\/revisions"}],"predecessor-version":[{"id":117,"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=\/wp\/v2\/posts\/110\/revisions\/117"}],"wp:attachment":[{"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hestben.se\/HestbenTechnical\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}