Reputation: 2458
When I connect to an FTP server (Pure-FTPd) with ftputil
, I get the following error:
import ftputil
from ftplib import FTP_TLS
class TLSFTPSession(FTP_TLS):
def __init__(self, host, userid, password):
FTP_TLS.__init__(self)
self.set_debuglevel(2)
self.connect(host, 21)
self.login(userid, password)
self.prot_p()
ftp = ftputil.FTPHost(host, user, pw, session_factory=TLSFTPSession)
This returns:
FTPOSError: [SSL: DH_KEY_TOO_SMALL] dh key too small (_ssl.c:997)
Debugging info: ftputil 5.0.4, Python 3.10.5 (win32)
So I tried to apply the solution I found here by adding self.context.set_ciphers('DEFAULT@SECLEVEL=1')
to the __init__
method of the custom TLSFTPSession
class:
class TLSFTPSession(FTP_TLS):
def __init__(self, host, userid, password):
FTP_TLS.__init__(self)
self.set_debuglevel(2)
self.connect(host, 21)
self.login(userid, password)
self.prot_p()
self.context.set_ciphers('DEFAULT@SECLEVEL=1')
However, this didn't help either. Any idea?
Upvotes: 0
Views: 162