私はpython ftplibで暗黙のtls接続プログラムを開発中です。私は問題python-ftp-implicit-tls-connection-issue(Rg GlpjとJuan Morenoの回答を含む)のソリューションを試して接続を試みました。私はEOFエラーまし Python ftplibとのプロトコル違反でEOFが発生しました
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()
:それはそうと
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)
がftplibのはPROTOCOL_SSLv23
を使用しています私はこのようなftpサーバにログインした後retrline
またはretrbinary
を呼び出すときにでも(FTP_ITLS
FTP_TLS
のサブクラスです) Python 2.7のデフォルトプロトコルとして PROTOCOL_TLSv1、PROTOCOL_TLSv1_1、およびPROTOCOL_TLSv1_2を試しましたが、いずれも機能しませんでした。また、connect-to-ftp-tls-1-2-server-with-ftplibでSteffen Ullrichが言ったようにntransfercmd
とauth
を無効にするか、ctx = ssl._create_stdlib_context(ssl.PROTOCOL_TLSv1)
に設定しましたが、エラーは消えませんでした。私は何をすることができますか?ありがとう。