title: Issues connecting to server with sslv3 disabled in legacy perl
body: <p>As the title says, I'm attempting to POST some JSON to a REST API using a pretty old version of perl, specifically 5.10.1. I'm working in a pretty old legacy codebase on RHEL 6. The handshake fails with error 500 because the server has sslv3 disabled. However I'm using versions of LWP and IO::Socket::SSL that I believe nominally support at least TLSv1, which the server supports so I'm unsure why the connection fails as it should just use an acceptable cipher. The server appears to be behind a cloudfront reverse proxy which may be relevant. I don't know enough about SSL to say for certain, but it appears that the issue is in the way the server I care about is set up and how the version of perl and libraries in use implement the cipher. Using an online <a href="https://www.ssllabs.com/ssltest/analyze.html?d=dev.superquoteapi.fis.rcuh.com&amp;s=99.84.224.116&amp;latest" rel="nofollow noreferrer">tool</a> I noticed that the handshake fails on several browsers that do not support SNI. The version of openssl available should support this, but neither of the perl SSL implementations appear to. Is there a way around this? </p>
  
  <p><a href="https://stackoverflow.com/questions/49166769/using-perl-5-8-8-with-openssl-1-0-1-to-connect-with-tlsv1-2">this</a> question seems to be dealing with a similar issue, but they solve it by installing a newer version of perl, which I'm not sure I can do given that this would likely break large portions of the codebase.</p>
  
  <p><a href="https://bugzilla.redhat.com/show_bug.cgi?id=1355802" rel="nofollow noreferrer">This</a> unresolved bug seems to accidentally document this behavior
  my problem is identical to the one listed, but I can also connect to the openssl host. I'm not sure that it's the same problem but I am on the same version of redhat with the same software and the same inconsistent behavior so it seems valuable. If it helps  my software versions are as follows</p>
  
  <pre><code>openssl-1.0.1e-58.el6_10.i686
  perl-Crypt-SSLeay-0.57-17.el6.x86_64
  perl-IO-Socket-SSL-1.31-3.el6_8.2.noarch
  perl-Net-SSLeay-1.35-10.el6_8.1.x86_64
  </code></pre>
  
  <p>If I run  </p>
  
  <p><code>printf 'HTTP/1.0 200 Ok\r\n\r\n' | openssl s_server -accept 2000 -cert certificate.pem -key key.pem -no_ssl2 -no_ssl3 -no_tls1</code></p>
  
  <p>the following script (test.pl) is able to connect using the same libraries </p>
  
  <pre><code>my $ua = LWP::UserAgent-&gt;new(timeout =&gt; 600);
  my $req = HTTP::Request-&gt;new(POST =&gt; $ARGV[0]);
  $req-&gt;content_type('application/json');
  $req-&gt;content_encoding('gzip');
  $req-&gt;content('');
  my $res = $ua-&gt;request($req);
  print $res-&gt;status_line, "\n";
  </code></pre>
  
  <pre><code>&gt;perl5.10.1 test.pl https://localhost:2000/
  200 Ok
  </code></pre>
  
  <p>However, when I run an only slightly more complicated program using the same libraries and perl version I get errors relating to the sslv3 handshake</p>
  
  <pre><code>500 Can't connect to dev.superquoteapi.fis.rcuh.com:443 (SSL connect attempt failed with unknown errorerror:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure)
  </code></pre>
  
  <p>I've even tried to force the program to use only TLSv1, but to no avail, the following line seems to have no impact</p>
  
  <pre><code>my $ua = LWP::UserAgent-&gt;new(ssl_opts =&gt; {verify_hostname =&gt; 0}, SSL_version =&gt; '!TLSv12:TLSv1:!SSLv2:!SSLv3', allowed_protocols =&gt; ['https']);
  </code></pre>
  
  <p>The program I am actually working with is listed below</p>
  
  <pre><code>use LWP;
  use IO::Socket::SSL;
  my $ua = LWP::UserAgent-&gt;new(ssl_opts =&gt; {verify_hostname =&gt; 0}, SSL_version =&gt; '!TLSv12:TLSv1:!SSLv2:!SSLv3', allowed_protocols =&gt; ['https']);
  
  my $req = HTTP::Request-&gt;new('POST', 'https://dev.superquoteapi.fis.rcuh.com:443/api/quote');
  
  $req-&gt;header('Content-Type' =&gt; 'application/json');
  $req-&gt;header('Accept' =&gt; 'application/json');
  #an api key is required and set in a header, but I won't list that here
  
  open(my $fd, '&lt;', 'data,json') 
      or die "Unable to open file, $!";
  my @json=&lt;$fd&gt;;
  close($fd)
      or warn "Unable to close the file handle: $!";
  $req-&gt;content(@json);
  my $resp = $ua-&gt;request($req);
  print $resp-&gt;as_string;
  </code></pre>
  
  <p>I have tried removing <code>IO::Socket::SSL</code> and replacing it with <code>Net::SSL</code> as is referenced in this question <a href="https://stackoverflow.com/questions/8026524/how-do-i-force-lwp-to-use-cryptssleay-for-https-requests">How do I force LWP to use Crypt::SSLeay for HTTPS requests?</a> but this does not seem to help. The code I used was </p>
  
  <pre><code>use Net::SSL ();
  BEGIN {
    $Net::HTTPS::SSL_SOCKET_CLASS = "Net::SSL"; # Force use of Net::SSL
  }
  </code></pre>
  
  <p>The two programs are more or less identical. The issue seems to be in the way the specific server <code>https://dev.superquoteapi.fis.rcuh.com</code> handles ssl requests. However I do not know enough about SSL/TLS to verify this meaningfully, so I have included both for completeness.</p>
  
  <p>I apologize if this question is a bit rambling, but I really need help, and I just want to provide as much information as I can. If I can provide further information, or remove unhelpful information please let me know, I am absolutely at my wits end.</p>