{"id":72,"date":"2014-07-17T15:26:39","date_gmt":"2014-07-17T20:26:39","guid":{"rendered":"http:\/\/www.dbadillo.com\/?p=72"},"modified":"2014-07-17T15:26:39","modified_gmt":"2014-07-17T20:26:39","slug":"activacion-de-tls-en-sendmail","status":"publish","type":"post","link":"https:\/\/www.dbadillo.com\/?p=72","title":{"rendered":"Activaci\u00f3n de TLS en Sendmail"},"content":{"rendered":"<p>TLS permite asegurar el servicio de correo, mediante un cifrado est\u00e1ndar. Esto quiere decir que se reduce el riesgo de que los correos sean interceptados y le\u00eddos por personas no autorizadas.<\/p>\n<p>El presente aporte, trata de como implementar TLS en Sendmail bajo CentOS 6.<\/p>\n<p>Lo primero que debemos hacer, es verificar que est\u00e9n instalado los siguientes paquetes:<\/p>\n<pre><strong><span style=\"color: #888888;\">cyrus-sasl cyrus-sasl-plain<\/span><\/strong><\/pre>\n<p>Levantar el servicio:<\/p>\n<pre style=\"padding-left: 30px;\"><span style=\"color: #888888;\"><strong>[root@mail ~]# service saslauthd start\r\n\r\n<\/strong><strong>[root@mail ~]# chkconfig saslauthd on<\/strong><\/span><\/pre>\n<p>Luego generamos los certificados necesarios, para ello debemos eliminar el certificado por defecto (si existe) asociado a localhost:<\/p>\n<pre style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail ~]#rm -f \/etc\/pki\/tls\/certs\/sendmail.pem<\/span><\/strong><\/pre>\n<p>Luego ejecutamos lo siguiente:<\/p>\n<p>Ir al directorio:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail ~]# cd \/etc\/pki\/tls\/certs\/<\/span><\/strong><\/p>\n<p>General los certificados, llenamos los datos. Ver el tema de: \u00a0Common Name (eg, your name or your server&#8217;s hostname) []:<strong>dominio.com<\/strong><\/p>\n<pre><\/pre>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail certs]# openssl req -new -x509 -nodes -newkey rsa:2048 -days 1825 -out \/etc\/pki\/tls\/certs\/sendmail.pem -keyout \/etc\/pki\/tls\/certs\/sendmail.pem<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail certs]#\u00a0openssl x509 -subject -fingerprint -noout -in \/etc\/pki\/tls\/certs\/sendmail.pem<\/span><\/strong><\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail certs]# chmod 400 sendmail.pem<\/span><\/strong><\/p>\n<p>Editar el archivo saslauthd:<\/p>\n<pre style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail certs]# vi \/etc\/sysconfig\/saslauthd<\/span><\/strong><\/pre>\n<p>Dejarlo as\u00ed:<\/p>\n<p style=\"padding-left: 30px;\"><em># Directory in which to place saslauthd&#8217;s listening socket, pid file, and so<\/em><br \/>\n<em># on. This directory must already exist.<\/em><br \/>\n<em>SOCKETDIR=\/var\/run\/saslauthd<\/em><\/p>\n<p style=\"padding-left: 30px;\"><em># Mechanism to use when checking passwords. Run \u00absaslauthd -v\u00bb to get a list<\/em><br \/>\n<em># of which mechanism your installation was compiled with the ablity to use.<\/em><br \/>\n<em>MECH=pam<\/em><\/p>\n<p style=\"padding-left: 30px;\"><em># Options sent to the saslauthd. If the MECH is other than \u00abpam\u00bb uncomment the next line.<\/em><br \/>\n<em># DAEMONOPTS=&#8211;user saslauth<\/em><\/p>\n<p style=\"padding-left: 30px;\"><em># Additional flags to pass to saslauthd on the command line. See saslauthd(8)<\/em><br \/>\n<em># for the list of accepted flags.<\/em><br \/>\n<em>FLAGS=\u00bb-n 2&#8243;<\/em><\/p>\n<p>Luego editamos en la configuraci\u00f3n del sendmail y en la secci\u00f3n de TLS, le dejamos as\u00ed:<\/p>\n<p style=\"padding-left: 30px;\"><em>dnl<\/em><br \/>\n<em>dnl #<\/em><br \/>\n<em>dnl # Rudimentary information on creating certificates for sendmail TLS:<\/em><br \/>\n<em>dnl # cd \/usr\/share\/ssl\/certs; make sendmail.pem<\/em><br \/>\n<em>dnl # Complete usage:<\/em><br \/>\n<em>dnl # make -C \/usr\/share\/ssl\/certs usage<\/em><br \/>\n<em>dnl #<\/em><br \/>\n<em>define(`confCACERT_PATH&#8217;, `\/etc\/pki\/tls\/certs&#8217;)dnl<\/em><br \/>\n<em>define(`confCACERT&#8217;, `\/etc\/pki\/tls\/certs\/ca-bundle.crt&#8217;)dnl<\/em><br \/>\n<em>define(`confSERVER_CERT&#8217;, `\/etc\/pki\/tls\/certs\/sendmail.pem&#8217;)dnl<\/em><br \/>\n<em>define(`confSERVER_KEY&#8217;, `\/etc\/pki\/tls\/certs\/sendmail.pem&#8217;)dnl<\/em><br \/>\n<em>define(`confCLIENT_CERT&#8217;, `\/etc\/pki\/tls\/certs\/sendmail.pem&#8217;)dnl<\/em><br \/>\n<em>define(`confCLIENT_KEY&#8217;, `\/etc\/pki\/tls\/certs\/sendmail.pem&#8217;)dnl<\/em><\/p>\n<p>Luego ejecutamos el m4:<\/p>\n<p style=\"padding-left: 30px;\"><strong><span style=\"color: #888888;\">[root@mail certs]# m4 \/etc\/mail\/sendmail.mc &gt; \/etc\/mail\/sendmail.cf<\/span><\/strong><\/p>\n<p>Reiniciamos el sendmail:<\/p>\n<p style=\"padding-left: 30px;\"><span style=\"color: #888888;\"><strong>[root@mail certs]# service sendmail restart<\/strong><\/span><\/p>\n<p style=\"text-align: left;\">Podemos comprobar que est\u00e9 activado con telnet, ejecutando <strong>ehlo, <\/strong>debe salir<strong>\u00a0<strong>250-STARTTLS<\/strong><\/strong><\/p>\n<p style=\"padding-left: 30px;\">[dbadillo@localhost ~]$ telnet dominio.com 587<br \/>\nTrying X.X.X.X&#8230;<br \/>\nConnected to dominio.com.<br \/>\nEscape character is &#8216;^]&#8217;.<br \/>\n220 mail.dominio.com ESMTP<\/p>\n<p style=\"padding-left: 30px;\"><strong>ehlo dominio.com<\/strong><br \/>\n250-mail.dominio.com Hello \u00a0(may be forged), pleased to meet you<br \/>\n250-ENHANCEDSTATUSCODES<br \/>\n250-PIPELINING<br \/>\n250-8BITMIME<br \/>\n250-SIZE<br \/>\n250-DSN<br \/>\n250-AUTH DIGEST-MD5 CRAM-MD5<br \/>\n<strong>250-STARTTLS<\/strong><br \/>\n250-DELIVERBY<br \/>\n250 HELP<\/p>\n<p>Una vez comprobado lo que nos queda es crear los usuarios y asignar la contrase\u00f1a, esto lo hacemos:<\/p>\n<p style=\"padding-left: 30px;\">[root@mail ~]# adduser usuario<\/p>\n<p style=\"padding-left: 30px;\">[root@mail ~]# passwd usuario<\/p>\n<p style=\"padding-left: 30px;\">[root@mail ~]#\u00a0saslpasswd2 usuario<\/p>\n<p style=\"text-align: left;\">Listo!!!<\/p>\n<p style=\"text-align: left;\">Lo que queda es en el cliente de correo seleccionar autenticaci\u00f3n (TLS acepta cualquier certificado).<\/p>\n<p style=\"padding-left: 30px;\">\n","protected":false},"excerpt":{"rendered":"<p>TLS permite asegurar el servicio de correo, mediante un cifrado est\u00e1ndar. Esto quiere decir que se reduce el riesgo de <span class=\"ellipsis\">&hellip;<\/span> <span class=\"more-link-wrap\"><a href=\"https:\/\/www.dbadillo.com\/?p=72\" class=\"more-link\"><span>Read More &rarr;<\/span><\/a><\/span><\/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":[],"class_list":["post-72","post","type-post","status-publish","format-standard","hentry","category-sin-categoria"],"_links":{"self":[{"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=\/wp\/v2\/posts\/72"}],"collection":[{"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=72"}],"version-history":[{"count":3,"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions"}],"predecessor-version":[{"id":75,"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=\/wp\/v2\/posts\/72\/revisions\/75"}],"wp:attachment":[{"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=72"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=72"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbadillo.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=72"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}