Subject: | TLS 1.0 Deprecation Compatibility |
Date: | Fri, 20 Oct 2017 12:46:21 -0600 |
To: | bug-net-ftpssl [...] rt.cpan.org |
From: | Benjamin Sautter <bsautter33 [...] gmail.com> |
Hello,
I have discovered an issue of compatibility, generically with FTP servers
that actively block TLS 1.0, and specifically with PureFTP v1.0.45 where it
states:
"TLS v1.0 sessions are now refused."
https://www.pureftpd.org/project/pure-ftpd/news
Everyone is trying to move to TLS v1.1+ due to the security problems of
1.0. However when interacting with such a server, the behavior of the
module is that it fails with $! = "Connection reset by peer". See a code
sample and censored debug output below.
This issue is present both on the latest 0.38 and on 0.35 which I was using.
I believe the cause to be on line 395 in Net::FTPSSL.pm:
my $mode = $use_ssl ? "SSLv23" : "TLSv1";
This explicitly sets a variable later used in a request for IO-Socket-SSL
to use v1, even if v1.1 and v1.2 are available. With no compatible protocol
between server and client, the remote server refuses the handshake.
I tested a simple fix of changing that variable to "TLSv12" instead and the
connection succeeded. Perhaps an update could be made to allow the choice
of TLS version.
Thanks.
========================================
# (the host was over IPv4)
use IO::Socket::SSL qw(debug4);
use Net::FTPSSL;
IO::Socket::SSL::set_defaults('SSL_verify_mode',SSL_VERIFY_NONE);
my $ftp = Net::FTPSSL->new($host, Debug => 1, Port => $port) or die
"Couldn't connect to URL: $!";
========================================
Net-FTPSSL Version: 0.35
IO-Socket-INET Version: 1.31
IO-Socket-SSL Version: 2.040
No IPv6 support available. Missing required modules!
Perl: 5.012002 [5.12.2], OS: linux
***** IPv6 not yet supported in Net::FTPSSL! *****
SKT >>> AUTH TLS
SKT <<< 234 AUTH TLS OK.
DEBUG: .../IO/Socket/SSL.pm:2773: new ctx 15545280
DEBUG: .../IO/Socket/SSL.pm:1473: start handshake
DEBUG: .../IO/Socket/SSL.pm:654: ssl handshake not started
DEBUG: .../IO/Socket/SSL.pm:687: using SNI with hostname ********
DEBUG: .../IO/Socket/SSL.pm:743: set socket to non-blocking to enforce
timeout=120
DEBUG: .../IO/Socket/SSL.pm:756: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:759: done Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:769: ssl handshake in progress
DEBUG: .../IO/Socket/SSL.pm:779: waiting for fd to become ready: SSL wants
a read first
DEBUG: .../IO/Socket/SSL.pm:799: socket ready, retrying connect
DEBUG: .../IO/Socket/SSL.pm:756: call Net::SSLeay::connect
DEBUG: .../IO/Socket/SSL.pm:759: done Net::SSLeay::connect -> -1
DEBUG: .../IO/Socket/SSL.pm:762: local error: SSL connect attempt failed
DEBUG: .../IO/Socket/SSL.pm:765: fatal SSL error: SSL connect attempt failed
DEBUG: .../IO/Socket/SSL.pm:2795: free ctx 15545280 open=15545280
DEBUG: .../IO/Socket/SSL.pm:2807: OK free ctx 15545280
Couldn't connect to URL: Connection reset by peer
Message body is not shown because it is too large.