Ich arbeite an einem impliziten Tls-Verbindungsprogramm mit Python ftplib. Ich versuchte die Lösung in Frage python-ftp-implicit-tls-connection-issue (einschließlich Rg Glpj und Juan Moreno Antworten), um die Verbindung herzustellen. Aber wenn ich rufe retrline
oder retrbinary
nach wie dies in den FTP-Server anmelden (FTP_ITLS
ist die Unterklasse von FTP_TLS
):EOF trat in Verletzung des Protokolls mit Python ftplib
58 server = FTP_ITLS()
59 server.connect(host="x.x.x.x", port=990)
60 server.login(user="user", passwd="******")
61 server.prot_p()
62
63 server.cwd("doc")
64 print(server.retrlines('LIST'))
65 # server.retrbinary('RETR contents.7z', open('contents.7z', 'wb').write)
66 server.quit()
ich einen EOF Fehler bekam:
Traceback (most recent call last):
File "D:/Coding/test/itls.py", line 64, in <module>
print(server.retrlines('LIST'))
File "D:\Python\Python27\lib\ftplib.py", line 735, in retrlines
conn = self.transfercmd(cmd)
File "D:\Python\Python27\lib\ftplib.py", line 376, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "D:\Python\Python27\lib\ftplib.py", line 713, in ntransfercmd
server_hostname=self.host)
File "D:\Python\Python27\lib\ssl.py", line 352, in wrap_socket
_context=self)
File "D:\Python\Python27\lib\ssl.py", line 579, in __init__
self.do_handshake()
File "D:\Python\Python27\lib\ssl.py", line 808, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:590)
Wie es ftplib scheint verwendet PROTOCOL_SSLv23
Als Standardprotokoll in Python 2.7 habe ich versucht PROTOCOL_TLSv1, PROTOCOL_TLSv1_1 und PROTOCOL_TLSv1_2, aber keiner von ihnen funktionierte. Und ich habe auch versucht, ntransfercmd
und auth
oder Einstellung ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1)
wie Steffen Ullrich sagte in Frage connect-to-ftp-tls-1-2-server-with-ftplib überschrieben, aber der Fehler nie verschwunden. Was kann ich dann tun? Vielen Dank.