Search code examples
pythonftpftps

Python FTPS (FTP_TLS) connection refused. No certificate?


I would like to download a file over ftps.

When I try to download that file with wget, I have to include the --no-check-certificate for it to work, but I could not find a parallel setting in ftplib.

from ftplib import FTP_TLS

host = "www-i6.informatik.rwth-aachen.de"
file = "/pub/rwth-phoenix/2016/phoenix-2014-T.v3.tar.gz"

ftp = FTP_TLS(host)
ftp.login()

print("size", ftp.size(file))

ftp.retrbinary("RETR " + file, print)

It does print out the size (size 41699758035), but when trying to retrieve the file it gives an error:

ConnectionRefusedError: [Errno 111] Connection refused

Is it a problem with the certificate? If so, how can I ignore the certificate?


Edit

Using debuglevel=2, this is the ftp log:

*cmd* 'AUTH TLS'
*put* 'AUTH TLS\r\n'
*get* '234 AUTH TLS OK.\n'
*resp* '234 AUTH TLS OK.'
*cmd* 'USER anonymous'
*put* 'USER anonymous\r\n'
*get* '230-**************************************************************\n'
*get* '230-***                                                        ***\n'
*get* '230-***          Willkommen auf dem FTP-Server des             ***\n'
*get* '230-***                                                        ***\n'
*get* '230-***          Lehrstuhl fuer Informatik VI der              ***\n'
*get* '230-***                                                        ***\n'
*get* '230-*** Rheinisch-Westfaelischen Technischen Hochschule Aachen *** \n'
*get* '230-***                                                        ***\n'
*get* '230-**************************************************************\n'
*get* '230-\n'
*get* '230 Anonymous user logged in\n'
*resp* '230-**************************************************************\n230-***                                                        ***\n230-***          Willkommen auf dem FTP-Server des             ***\n230-***                                                        ***\n230-***          Lehrstuhl fuer Informatik VI der              ***\n230-***                                                        ***\n230-*** Rheinisch-Westfaelischen Technischen Hochschule Aachen *** \n230-***                                                        ***\n230-**************************************************************\n230-\n230 Anonymous user logged in'
*cmd* 'TYPE I'
*put* 'TYPE I\r\n'
*get* '200 TYPE is now 8-bit binary\n'
*resp* '200 TYPE is now 8-bit binary'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (137,226,36,140,182,135)\n'
*resp* '227 Entering Passive Mode (137,226,36,140,182,135)'

ConnectionRefusedError: [Errno 111] Connection refused

Solution

  • Firefall blocked the connection. No way to solve except changing firewall rules on the end server.