{"id":1256,"date":"2013-06-25T16:40:19","date_gmt":"2013-06-25T15:40:19","guid":{"rendered":"http:\/\/www.michaelm.info\/blog\/?p=1256"},"modified":"2013-06-25T16:49:53","modified_gmt":"2013-06-25T15:49:53","slug":"configuration-of-hidden-sendmail-ssltls-connection-options","status":"publish","type":"post","link":"http:\/\/www.michaelm.info\/blog\/?p=1256","title":{"rendered":"Configuration of hidden Sendmail SSL\/TLS connection options"},"content":{"rendered":"<p>Sendmail has done it again &#8211; proved just how powerful it is, as long as you know what you&#8217;re doing.<\/p>\n<p>While investigating the configuration of the ciphers to used by Apache (<code>SSLCipherSuite<\/code>) and the associated <code>SSLHonorCipherOrder<\/code> option (to ensure the server&#8217;s cipher preference order is used), I realised that although I enable TLS on my Sendmail instances I don&#8217;t configure the cipher options. Given I&#8217;d spent some time coming up with my preferred cipher order for Apache (unfortunately RC4-SHA is fairly high on the list) I decided I may as well put it in place for other daemons which perform OpenSSL based encryption (Sendmail and IMAP for instance). Given the available Sendmail documentation is light on this subject I had to go digging.<\/p>\n<p>The &#8220;standard&#8221; encryption related options (enabled with the <code>STARTTLS<\/code> define at compilation time) for Sendmail are pretty <a title=\"Sendmail configuration guide\" href=\"http:\/\/www.sendmail.co.uk\/sm\/open_source\/docs\/configuration_readme\/\" target=\"_blank\">well documented<\/a> and understood:<br \/>\n<code>ServerCertFile<br \/>\nServerKeyFile<br \/>\nClientCertFile<br \/>\nClientKeyFile<br \/>\nCACertFile<br \/>\nCACertPath<br \/>\nDHParameters<br \/>\nTLSSrvOptions<br \/>\nRandFile<br \/>\nCRLFile<\/code><\/p>\n<p>There are some other useful options available when the <code>STARTTLS<\/code> define is combined with the <code>_FFR_TLS_1<\/code> define at compile time.<br \/>\n<code>DHParameters512<br \/>\nCipherList<br \/>\nServerSSLOptions<br \/>\nClientSSLOptions<\/code><\/p>\n<p>&nbsp;<\/p>\n<p style=\"padding-left: 60px;\">Note:\u00a0You can determine the compile settings used for your version of Sendmail by running:<\/p>\n<p style=\"padding-left: 60px;\"><code>sendmail -d0.14 -bt &lt; \/dev\/null<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>These four options do not appear to be documented properly anywhere &#8211; even the Sendmail source code is pretty light on their configuration syntax and use. The <code>CipherList<\/code> option is mentioned as an available option on a page titled &#8220;<a href=\"http:\/\/www.sendmail.org\/~ca\/email\/tricks.html\" target=\"_blank\">Tips and Tricks for Sendmail Hackers<\/a>&#8220;, dated 2006-03-31. There are a few other web pages and blog posts which mention or show one how to use the <code>CipherList<\/code> option. No mention is made of the remaining three.<\/p>\n<p>These four options are configured in the <code>LOCAL_CONFIG<\/code> section of your <code>sendmail.mc<\/code> file. The following is an example (which may or may not be suitable for you) of such a section:<\/p>\n<p><code>LOCAL_CONFIG<br \/>\nO CipherList=HIGH:RC4-SHA:RC4-MD5<br \/>\nO\u00a0ServerSSLOptions=+SSL_OP_NO_SSLv2 +SSL_OP_CIPHER_SERVER_PREFERENCE<br \/>\n<\/code><\/p>\n<p>&nbsp;<\/p>\n<p>The options described:<\/p>\n<p><strong><code>CipherList<\/code><\/strong> : This option configures the available cipher list for encrypted connections. Your cipher list can be tuned by using the <a title=\"openssl ciphers\" href=\"http:\/\/www.openssl.org\/docs\/apps\/ciphers.html\" target=\"_blank\"><code>openssl ciphers -v<\/code><\/a> command. Stronger ciphers are obviously better. Excluding weak ciphers may mean that very old clients will be unable to connect. Note that with SSLv3 and TLS1.x the client, by default, will select its preferred cipher from the server&#8217;s list.<\/p>\n<p><strong><code>ServerSSLOptions<\/code><\/strong> : This option configures the <a title=\"OpenSSL options\" href=\"http:\/\/www.openssl.org\/docs\/ssl\/SSL_CTX_set_options.html\" target=\"_blank\">OpenSSL connection flags<\/a>\u00a0used for the SSL\/TLS connections into Sendmail. By default Sendmail, and most other applications using the OpenSSL library, uses the <code>SSL_OP_ALL<\/code> composite flag for its connections. This option allows these flags to be altered. The first option to consider using is\u00a0<code>SSL_OP_CIPHER_SERVER_PREFERENCE<\/code>. This option causes the server, rather than the client, to choose the cipher based on its preference order. The next option to consider is <code>SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS<\/code>. This option disables a countermeasure against a SSLv3\/TLSv1 protocol vulnerability. This flag disables the countermeasure and is set by default when <code>SSL_OP_ALL<\/code> is used. Thus, if one wishes to have the vulnerability countermeasure enabled, this flag needs to be disabled. Depending on the clients and servers of your Sendmail instance you may wish to consider the use of <code>SSL_OP_NO_SSLv2<\/code>, <code>SSL_OP_NO_SSLv3<\/code> and <code>SSL_OP_NO_TLSv1<\/code>. Note that the current version of Sendmail does not have support for OpenSSL&#8217;s <code>SSL_OP_NO_TLS_v1_1<\/code> nor for <code>SSL_OP_NO_TLSv1_2<\/code>. These two could be quite useful and I have submitted a patch to Sendmail for these to be included. The value of this parameter is used to manipulate the bits passed to OpenSSL. Note that Sendmail starts with a value of <code>SSL_OP_ALL<\/code> and this option modifies that value &#8211; it does not reset it from scratch. You manipulate the value using <code>[+]SSL_OP_XXX<\/code> to SET the bits and using <code>-SSL_OP_XXX<\/code> to CLEAR the bits. Thus a value of <code>+SSL_OP_ALL<\/code> would have no effect (since those bits are already set. A value of <code>-SSL_OP_ALL<\/code> would result in no bits being set. A useful value might be <code>+SSL_OP_NO_SSLv2 +SSL_OP_CIPHER_SERVER_PREFERENCE<\/code>.<\/p>\n<p><strong><code>ClientSSLOptions<\/code><\/strong>\u00a0: This option\u00a0configures the\u00a0<a title=\"OpenSSL options\" href=\"http:\/\/www.openssl.org\/docs\/ssl\/SSL_CTX_set_options.html\" target=\"_blank\">OpenSSL connection flags<\/a>\u00a0used for the SSL\/TLS connections initiated by Sendmail. The parameter&#8217;s value works the same as for\u00a0<code>ServerSSLOptions<\/code>.<\/p>\n<p><code><strong>DHParameters512<\/strong><\/code> : This option does not appear to actually be used. It is a valid configuration option which will be parsed. However, it appears as if this parameter is not used by the Sendmail source code at all!<\/p>\n<p>&nbsp;<\/p>\n<p>As an aside, <code><strong>DHParameters<\/strong><\/code> is another odd configuration option. The documentation implies this is a file containing DH paramters. However, the source code in <code>sendmail\/tls.c<\/code> has this to say:<br \/>\n<code><br \/>\n\/*<br \/>\n** valid values for dhparam are (only the first char is checked)<br \/>\n** none no parameters: don't use DH<br \/>\n** 512 generate 512 bit parameters (fixed)<br \/>\n** 1024 generate 1024 bit parameters<br \/>\n** \/file\/name read parameters from \/file\/name<br \/>\n** default is: 1024 for server, 512 for client (OK? XXX)<br \/>\n*\/<br \/>\n<\/code><\/p>\n<p>So in fact, it is slightly more flexible than the documentation makes out. Note too, that should you wish to use a DH parameter of more than 1024 bits you will need to use an external file.<\/p>\n<p>So with all that said, a useful set of parameters might be:<br \/>\n<code>LOCAL_CONFIG<br \/>\nO CipherList=HIGH:RC4-SHA:RC4-MD5<br \/>\nO\u00a0ServerSSLOptions=+SSL_OP_NO_SSLv2 +SSL_OP_CIPHER_SERVER_PREFERENCE<br \/>\nO\u00a0ClientSSLOptions=+SSL_OP_NO_SSLv2<br \/>\n<\/code><\/p>\n<p>So, based on this configuration, we are only using &#8220;high&#8221; strength ciphers and also two RC4 ciphers. You may want to remove the RC4-MD5 one if you are concerned about MD5&#8217;s strength. For maximum compatibility with old clients, you may want to keep it included. We don&#8217;t allow SSLv2 and we request that the server (i.e. our Sendmail instance) chooses the mutual cipher.<\/p>\n<p>Hope this helps.<\/p>\n<p>Another useful thing to note, is that when <code>_FFR_TLS_1<\/code> is used you can use two certificates and key files for <code>ServerCertFile<\/code> and <code>ServerKeyFile<\/code> &#8211; with their names separated with simply a <code>,<\/code> (i.e. a comma and no spaces). This is useful if you have both an RSA and DSA certificate you wish to use. For example, the configured option within sendmail.cf would be:<\/p>\n<p><code><br \/>\nO ServerCertFile=\/etc\/mail\/tls\/server-rsa.crt,\/etc\/mail\/tls\/server-dsa.crt<br \/>\nO ServerKeyFile=\/etc\/mail\/tls\/server-rsa.key,\/etc\/mail\/tls\/server-dsa.key<br \/>\n<\/code><\/p>\n<p>Due to constraints within OpenSSL&#8217;s <code>SSL_CTX_use_PrivateKey_file<\/code> and <code>SSL_CTX_use_certificate_file<\/code> calls, both certificates should use the same certificate chain. More information can be found on <a title=\"OpenSSL SSL_CTX_use_certificate\" href=\"http:\/\/www.openssl.org\/docs\/ssl\/SSL_CTX_use_certificate.html\" target=\"_blank\">OpenSSL&#8217;s website<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sendmail has done it again &#8211; proved just how powerful it is, as long as you know what you&#8217;re doing. While investigating the configuration of the ciphers to used by Apache (SSLCipherSuite) and the associated SSLHonorCipherOrder option (to ensure the server&#8217;s cipher preference order is used), I realised that although I enable TLS on my [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[12],"tags":[134,135,140,139,144,143,145,142,141],"class_list":["post-1256","post","type-post","status-publish","format-standard","hentry","category-technical","tag-cipher","tag-encryption","tag-openssl","tag-sendmail","tag-sendmail-cf","tag-sendmail-mc","tag-ssl_op_cipher_server_preference","tag-sslv3","tag-tls"],"_links":{"self":[{"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1256"}],"version-history":[{"count":14,"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1256\/revisions"}],"predecessor-version":[{"id":1266,"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1256\/revisions\/1266"}],"wp:attachment":[{"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1256"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.michaelm.info\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}