git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] send-email: set SSL options through IO::Socket::SSL::set_client_defaults

From
Thomas Rast <tr@thomasrast.ch>
Date
Dec 1, 2013, 22:48 UTC
Message-ID
<c5308d5ffb34b70cbfea5a39e08902904fac1400.1385938050.git.tr@thomasrast.ch>
In-Reply-To
<3bb0c80c70e1c40236034552bec037cb0c26167c.1385938050.git.tr@thomasrast.ch>

When --smtp-encryption=ssl, we use a Net::SMTP::SSL connection, passing its ->new all the options that would otherwise go to Net::SMTP->new (most options) and IO::Socket::SSL->start_SSL (for the SSL options).

However, while Net::SMTP::SSL replaces the underlying socket class with an SSL socket, it does nothing to allow passing options to that socket. So the SSL-relevant options are lost.

Fortunately there is an escape hatch: we can directly set the options with IO::Socket::SSL::set_client_defaults. They will then persist within the IO::Socket::SSL module.

Signed-off-by: Thomas Rast <tr@thomasrast.ch>
---
 git-send-email.perl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 9f31c68..2016d9c 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1214,11 +1214,14 @@ sub send_message {
 			$smtp_server_port ||= 465; # ssmtp
 			require Net::SMTP::SSL;
 			$smtp_domain ||= maildomain();
+			require IO::Socket::SSL;
+			# Net::SMTP::SSL->new() does not forward any SSL options
+			IO::Socket::SSL::set_client_defaults(
+				ssl_verify_params());
 			$smtp ||= Net::SMTP::SSL->new($smtp_server,
 						      Hello => $smtp_domain,
 						      Port => $smtp_server_port,
-						      Debug => $debug_net_smtp,
-						      ssl_verify_params());
+						      Debug => $debug_net_smtp);
 		}
 		else {
 			require Net::SMTP;
-- 
1.8.5.rc3.5.g2a1fe2f
Previous: Thomas RastNext: Ramkumar Ramachandra
Message 3 of 5 in “send-email: pass Debug to Net::SMTP::SSL::new”
  1. 1/3 send-email: pass Debug to Net::SMTP::SSL::newThomas Rast, Dec 1, 2013
  2. 2/3 send-email: --smtp-ssl-cert-path takes an argumentThomas Rast, Dec 1, 2013
  3. 3/3 send-email: set SSL options through IO::Socket::SSL::set_client_defaultsThomas Rast, Dec 1, 2013
  4. Ramkumar RamachandraDec 2, 2013
  5. Thomas RastDec 2, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.