734417
From 5f39e47e30390af4288acf47a6d342874a803cbf Mon Sep 17 00:00:00 2001
734417
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
734417
Date: Wed, 21 Mar 2018 14:54:07 +0100
734417
Subject: [PATCH 4/4] use SNI for SSL support in SMTP
734417
MIME-Version: 1.0
734417
Content-Type: text/plain; charset=UTF-8
734417
Content-Transfer-Encoding: 8bit
734417
734417
Ported to Net::SMTP as found in Perl 5.16.3 from libnet upstream
734417
commit:
734417
734417
commit 50c6fd25f2958e6300ec8377ab40c3f1a23bd9fd
734417
Author: Steffen Ullrich <Steffen_Ullrich@genua.de>
734417
Date:   Fri Nov 28 11:47:16 2014 +0100
734417
734417
    - model SSL support for Net::NNTP after Net::SMTP, i.e. upgrade to SSL class instead of using IO::Socket::SSL in plain and SSL mode
734417
    - use SNI for SSL support in SMTP, NNTP, POP3, FTP by default
734417
734417
commit f2756a6b81ebfadbd1ce318879c20b6519207c49
734417
Author: Steffen Ullrich <Steffen_Ullrich@genua.de>
734417
Date:   Sat Nov 29 17:13:58 2014 +0100
734417
734417
    SSL support: use SNI only if supported by IO::Socket::SSL (i.e. openssl version>=1)
734417
734417
Other protocols excluded.
734417
734417
Signed-off-by: Petr Písař <ppisar@redhat.com>
734417
---
734417
 cpan/libnet/Net/SMTP.pm | 6 ++++--
734417
 1 file changed, 4 insertions(+), 2 deletions(-)
734417
734417
diff --git a/cpan/libnet/Net/SMTP.pm b/cpan/libnet/Net/SMTP.pm
734417
index 6475c86..d207c3c 100644
734417
--- a/cpan/libnet/Net/SMTP.pm
734417
+++ b/cpan/libnet/Net/SMTP.pm
734417
@@ -71,8 +71,9 @@ sub new {
734417
     unless defined $obj;
734417
 
734417
   ${*$obj}{'net_smtp_arg'} = \%arg;
734417
+  ${*$obj}{'net_smtp_host'} = $host;
734417
   if ($arg{SSL}) {
734417
-    Net::SMTP::_SSL->start_SSL($obj,SSL_verifycn_name => $host,%arg)
734417
+    Net::SMTP::_SSL->start_SSL($obj,%arg)
734417
       or return;
734417
   }
734417
 
734417
@@ -86,7 +87,6 @@ sub new {
734417
   }
734417
 
734417
   ${*$obj}{'net_smtp_exact_addr'} = $arg{ExactAddresses};
734417
-  ${*$obj}{'net_smtp_host'}       = $host;
734417
 
734417
   (${*$obj}{'net_smtp_banner'}) = $obj->message;
734417
   (${*$obj}{'net_smtp_domain'}) = $obj->message =~ /\A\s*(\S+)/;
734417
@@ -575,6 +575,8 @@ sub _STARTTLS { shift->command("STARTTLS", @_)->response() == CMD_OK }
734417
     delete @arg{ grep { !m{^SSL_} } keys %arg };
734417
     ( $arg{SSL_verifycn_name} ||= $smtp->host )
734417
 	=~s{(?
734417
+    $arg{SSL_hostname} = $arg{SSL_verifycn_name}
734417
+       if ! defined $arg{SSL_hostname} && $class->can_client_sni;
734417
     $arg{SSL_verifycn_scheme} ||= 'smtp';
734417
     $arg{SSL_verify_mode} ||= IO::Socket::SSL::SSL_VERIFY_PEER();
734417
     my $ok = $class->SUPER::start_SSL($smtp,%arg);
734417
-- 
734417
2.14.3
734417