Ubuntu 16.04 perl LWP SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure

SSL connect attempt failed error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure at /usr/share/perl5/LWP/Protocol/http.pm line 47.

openssl 1.0.2g-1ubuntu4.20
libio-socket-ssl-perl 2.024-1

#!/usr/bin/perl

use strict;

use HTTP::Request::Common; 
use HTTP::Status;
use LWP::UserAgent;

my $ua = LWP::UserAgent->new;

my $req = GET("https://slack.com");
my $s = $req->as_string;
print "Request:\n$s\n";

my $resp = $ua->request($req);
$s = $resp->as_string;
print "Response:\n$s\n";

以下エラー

Request:
GET https://slack.com


Response:
500 Can't connect to slack.com:443
Content-Type: text/plain
Client-Date: Thu, 01 Feb 2024 03:48:18 GMT
Client-Warning: Internal response

Can't connect to slack.com:443

SSL connect attempt failed error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure at /usr/share/perl5/LWP/Protocol/http.pm line 47.

以下で修正

my $ua = LWP::UserAgent->new(ssl_opts => { SSL_cipher_list => 'DEFAULT !EXP !MEDIUM !LOW !eNULL !aNULL !RC4 !DES !MD5 !PSK !SRP' });

IO::Socket::SSL 2.024がSSL_cipher_listをホワイトリスト指定していて、
使用できるchperがなくなったためと思われる。

/usr/share/perl5/LWP/Protocol/https.pm
/usr/share/perl5/Net/HTTPS.pm 
/usr/share/perl5/IO/Socket/SSL.pm 

2.024
    SSL_cipher_list => join(" ",
        qw(
            ECDHE-ECDSA-AES128-GCM-SHA256
            ECDHE-ECDSA-AES128-SHA256
            ECDHE-ECDSA-AES256-GCM-SHA384
            ...

2.084
    # rely on system default but be sure to disable some definitely bad ones
    SSL_cipher_list => 'DEFAULT !EXP !MEDIUM !LOW !eNULL !aNULL !RC4 !DES !MD5 !PSK !SRP',

TL;DR (too long, didn’t read) summary:

Force protocol and cipher:

my $ua = WWW::Mechanize->new();
$ua->ssl_opts(
  'SSL_version' => 'TLSv1_2',
  'SSL_cipher_list' => 'ECDHE-RSA-AES256-GCM-SHA384',
);

Perl WWW::Mechanize or LWP::UserAgent and AWS SSL Handshake Failure | newspaint 2020