Grégoire Chauvet <gchauvet.h...@gmail.com> added the comment:

I want to confirm that I have this exact same issue as described.

To add some information, it occurs on:
Python 3.6.3 on Windows
Python 3.6.5 on Debian, with OpenSSL 1.0.1t  3 May 2016
Python 3.5.3 on Debian, with OpenSSL 1.1.0f  25 May 2017
Python 3.6.5 on Fedora, with OpenSSL 1.1.0h-fips  27 Mar 2018
Python 3.8.0a0 on Fedora, with OpenSSL 1.1.0h-fips  27 Mar 2018

The server is FileZilla server 0.9.60 beta (this is the last version available 
as of today).

Depending on the version of python or OpenSSL, the error is :
  [...]
  File "/usr/lib64/python3.6/ssl.py", line 645, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error

Or:
  [...]
  File "/usr/local/lib/python3.6/ssl.py", line 689, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:833)


Here is my code:
# I use a workaround to connect with implicit TLS as described here:
# https://stackoverflow.com/a/36049814/3859915
# But from what I can see, it is not related to this.

import ssl
import ftplib

class ImplicitFTP_TLS(ftplib.FTP_TLS):
    """FTP_TLS subclass that automatically wraps sockets in SSL to support 
implicit FTPS."""
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._sock = None

    @property
    def sock(self):
        """Return the socket."""
        return self._sock

    @sock.setter
    def sock(self, value):
        """When modifying the socket, ensure that it is ssl wrapped."""
        if value is not None and not isinstance(value, ssl.SSLSocket):
            value = self.context.wrap_socket(value)
        self._sock = value

ftps = ImplicitFTP_TLS()
ftps.set_debuglevel(2)
ftps.connect(host="hostname", port=990)
ftps.login(user="user", passwd="password")
ftps.prot_p()
ftps.nlst()

I can connect, create directories, retrieve modification date, but I cannot 
list files nor download them.

----------
nosy: +Grégoire Chauvet

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue31727>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to