@@ -66,6 +66,8 @@ sub usage {
6666 --smtp-ssl-cert-path <str> * Path to ca-certificates (either directory or file).
6767 Pass an empty string to disable certificate
6868 verification.
69+ --smtp-ssl-client-cert <str> * Path to the client certificate file
70+ --smtp-ssl-client-key <str> * Path to the private key file for the client certificate
6971 --smtp-domain <str> * The domain name sent to HELO/EHLO handshake
7072 --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms, or
7173 "none" to disable authentication.
@@ -279,6 +281,7 @@ sub do_edit {
279281my ($to_cmd , $cc_cmd , $header_cmd );
280282my ($smtp_server , $smtp_server_port , @smtp_server_options );
281283my ($smtp_authuser , $smtp_encryption , $smtp_ssl_cert_path );
284+ my ($smtp_ssl_client_cert , $smtp_ssl_client_key );
282285my ($batch_size , $relogin_delay );
283286my ($identity , $aliasfiletype , @alias_files , $smtp_domain , $smtp_auth );
284287my ($imap_sent_folder );
@@ -350,6 +353,8 @@ sub do_edit {
350353my %config_path_settings = (
351354 " aliasesfile" => \@alias_files ,
352355 " smtpsslcertpath" => \$smtp_ssl_cert_path ,
356+ " smtpsslclientcert" => \$smtp_ssl_client_cert ,
357+ " smtpsslclientkey" => \$smtp_ssl_client_key ,
353358 " mailmap.file" => \$mailmap_file ,
354359 " mailmap.blob" => \$mailmap_blob ,
355360);
@@ -531,6 +536,8 @@ sub config_regexp {
531536 " smtp-ssl" => sub { $smtp_encryption = ' ssl' },
532537 " smtp-encryption=s" => \$smtp_encryption ,
533538 " smtp-ssl-cert-path=s" => \$smtp_ssl_cert_path ,
539+ " smtp-ssl-client-cert=s" => \$smtp_ssl_client_cert ,
540+ " smtp-ssl-client-key=s" => \$smtp_ssl_client_key ,
534541 " smtp-debug:i" => \$debug_net_smtp ,
535542 " smtp-domain:s" => \$smtp_domain ,
536543 " smtp-auth=s" => \$smtp_auth ,
@@ -1522,6 +1529,8 @@ sub handle_smtp_error {
15221529}
15231530
15241531sub ssl_verify_params {
1532+ my %ret = ();
1533+
15251534 eval {
15261535 require IO::Socket::SSL;
15271536 IO::Socket::SSL-> import (qw/ SSL_VERIFY_PEER SSL_VERIFY_NONE/ );
@@ -1533,20 +1542,36 @@ sub ssl_verify_params {
15331542
15341543 if (!defined $smtp_ssl_cert_path ) {
15351544 # use the OpenSSL defaults
1536- return (SSL_verify_mode => SSL_VERIFY_PEER());
1545+ $ret {SSL_verify_mode } = SSL_VERIFY_PEER();
1546+ }
1547+ else {
1548+ if ($smtp_ssl_cert_path eq " " ) {
1549+ $ret {SSL_verify_mode } = SSL_VERIFY_NONE();
1550+ } elsif (-d $smtp_ssl_cert_path ) {
1551+ $ret {SSL_verify_mode } = SSL_VERIFY_PEER();
1552+ $ret {SSL_ca_path } = $smtp_ssl_cert_path ;
1553+ } elsif (-f $smtp_ssl_cert_path ) {
1554+ $ret {SSL_verify_mode } = SSL_VERIFY_PEER();
1555+ $ret {SSL_ca_file } = $smtp_ssl_cert_path ;
1556+ } else {
1557+ die sprintf (__(" CA path \" %s \" does not exist" ), $smtp_ssl_cert_path );
1558+ }
15371559 }
15381560
1539- if ($smtp_ssl_cert_path eq " " ) {
1540- return (SSL_verify_mode => SSL_VERIFY_NONE());
1541- } elsif (-d $smtp_ssl_cert_path ) {
1542- return (SSL_verify_mode => SSL_VERIFY_PEER(),
1543- SSL_ca_path => $smtp_ssl_cert_path );
1544- } elsif (-f $smtp_ssl_cert_path ) {
1545- return (SSL_verify_mode => SSL_VERIFY_PEER(),
1546- SSL_ca_file => $smtp_ssl_cert_path );
1547- } else {
1548- die sprintf (__(" CA path \" %s \" does not exist" ), $smtp_ssl_cert_path );
1561+ if (defined $smtp_ssl_client_cert ) {
1562+ $ret {SSL_cert_file } = $smtp_ssl_client_cert ;
15491563 }
1564+ if (defined $smtp_ssl_client_key ) {
1565+ if (!defined $smtp_ssl_client_cert ) {
1566+ # Accept the client key only when a certificate is given.
1567+ # We die here because this case is a user error.
1568+ die sprintf (__(" Only client key \" %s \" specified" ),
1569+ $smtp_ssl_client_key );
1570+ }
1571+ $ret {SSL_key_file } = $smtp_ssl_client_key ;
1572+ }
1573+
1574+ return %ret ;
15501575}
15511576
15521577sub file_name_is_absolute {
0 commit comments