From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Keeping Subject: Re: [PATCH v2 2/2] send-email: introduce sendemail.smtpsslcertpath Date: Fri, 5 Jul 2013 19:43:33 +0100 Message-ID: <20130705184333.GN9161@serenity.lan> References: <1373025947-26495-1-git-send-email-artagnon@gmail.com> <1373025947-26495-3-git-send-email-artagnon@gmail.com> <20130705124536.GU862789@vauxhall.crustytoothpaste.net> <7vobag7wl0.fsf@alter.siamese.dyndns.org> <20130705174730.GM9161@serenity.lan> <7vehbc7tcc.fsf@alter.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: "brian m. carlson" , Ramkumar Ramachandra , Git List To: Junio C Hamano X-From: git-owner@vger.kernel.org Fri Jul 05 20:43:47 2013 Return-path: Envelope-to: gcvg-git-2@plane.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UvAyx-00081d-B2 for gcvg-git-2@plane.gmane.org; Fri, 05 Jul 2013 20:43:47 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757578Ab3GESnn (ORCPT ); Fri, 5 Jul 2013 14:43:43 -0400 Received: from hyena.aluminati.org ([64.22.123.221]:44499 "EHLO hyena.aluminati.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752241Ab3GESnm (ORCPT ); Fri, 5 Jul 2013 14:43:42 -0400 Received: from localhost (localhost [127.0.0.1]) by hyena.aluminati.org (Postfix) with ESMTP id 4456B23728; Fri, 5 Jul 2013 19:43:42 +0100 (BST) X-Virus-Scanned: Debian amavisd-new at hyena.aluminati.org X-Spam-Flag: NO X-Spam-Score: -2.9 X-Spam-Level: X-Spam-Status: No, score=-2.9 tagged_above=-9999 required=6.31 tests=[ALL_TRUSTED=-1, BAYES_00=-1.9] autolearn=ham Received: from hyena.aluminati.org ([127.0.0.1]) by localhost (hyena.aluminati.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id cr4UmLgGgLpp; Fri, 5 Jul 2013 19:43:41 +0100 (BST) Received: from serenity.lan (mink.aluminati.org [10.0.7.180]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by hyena.aluminati.org (Postfix) with ESMTPSA id CF0BA22F73; Fri, 5 Jul 2013 19:43:35 +0100 (BST) Content-Disposition: inline In-Reply-To: <7vehbc7tcc.fsf@alter.siamese.dyndns.org> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: On Fri, Jul 05, 2013 at 11:30:11AM -0700, Junio C Hamano wrote: > John Keeping writes: > > > On Fri, Jul 05, 2013 at 10:20:11AM -0700, Junio C Hamano wrote: > >> "brian m. carlson" writes: > >> > >> > You've covered the STARTTLS case, but not the SSL one right above it. > >> > Someone using smtps on port 465 will still see the warning. You can > >> > pass SSL_verify_mode to Net::SMTP::SSL->new just like you pass it to > >> > start_SSL. > >> > >> OK, will a fix-up look like this on top of 1/2 and 2/2? > > > > According to IO::Socket::SSL [1], if neither SSL_ca_file nor SSL_ca_path > > is specified then builtin defaults will be used, so I wonder if we > > should pass SSL_VERIFY_PEER regardless (possibly with a switch for > > SSL_VERIFY_NONE if people really need that). > > > > [1] http://search.cpan.org/~sullr/IO-Socket-SSL-1.951/lib/IO/Socket/SSL.pm > > Interesting. That frees us from saying "we assume /etc/ssl/cacerts > is the default location, and let the users override it". > > To help those "I do not want verification because I know my server > does not present valid certificate, I know my server is internal and > trustable, and I do not bother to fix it" people, we can let them > specify an empty string (or any non-directory) as the CACertPath, > and structure the code like so? > > if (defined $smtp_ssl_cert_path && -d $smtp_ssl_cert_path) { > return (SSL_verify_mode => SSL_VERIFY_PEER, > SSL_ca_path => $smtp_ssl_cert_path); > } elsif (defined $smtp_ssl_cert_path) { > return (SSL_verify_mode => SSL_VERIFY_NONE); > } else { > return (SSL_verify_mode => SSL_VERIFY_PEER); > } I'd rather have '$smtp_ssl_cert_path ne ""' in the first if condition (instead of the '-d $smtp_ssl_cert_path') but that seems reasonable and agrees with my reading of the documentation. Perhaps a complete solution could allow CA files as well: if (defined $smtp_ssl_cert_path) { if ($smtp_ssl_cert_path eq "") { return (SSL_verify_mode => SSL_VERIFY_NONE); } elsif (-f $smtp_ssl_cert_path) { return (SSL_verify_mode => SSL_VERIFY_PEER, SSL_ca_file => $smtp_ssl_cert_path); } else { return (SSL_verify_mode => SSL_VERIFY_PEER, SSL_ca_path => $smtp_ssl_cert_path); } } else { return (SSL_verify_mode => SSL_VERIFY_PEER); }