Feb-22-2023, 10:02 AM
First post here so I hope I've put everything I need. Thanks in advance!
I'm new to Python and trying to get my head around some basics.
I have a requirement to be able to connect to an FTPS (implicit on port 990) with username and password.
I've read quite a few snippets of code, but cannot get anything to work with FTPS (standard FTP is OK though).
I'm testing this on a Ubuntu 22.04 LTS server with vsFTPd v3.0.5. My python is 3.10.6.
vsFTPd is running and listening on port 990, TLS is v1.2. It has a valid certificate for the TLS connection and I can connect with a normal FTP client (tried Windows FlashFXP and Ubuntu lftp) successfully.
What I have so far is tried this code:
Thanks in advance!
I'm new to Python and trying to get my head around some basics.
I have a requirement to be able to connect to an FTPS (implicit on port 990) with username and password.
I've read quite a few snippets of code, but cannot get anything to work with FTPS (standard FTP is OK though).
I'm testing this on a Ubuntu 22.04 LTS server with vsFTPd v3.0.5. My python is 3.10.6.
vsFTPd is running and listening on port 990, TLS is v1.2. It has a valid certificate for the TLS connection and I can connect with a normal FTP client (tried Windows FlashFXP and Ubuntu lftp) successfully.
What I have so far is tried this code:
from ftplib import FTP_TLS import ssl def connect(): ftp = FTP_TLS() ftp.ssl_version = ssl.PROTOCOL_TLSv1_2 ftp.auth() ftp.prot_p() ftp.connect(host='testsvr3', port=990) ftp.login(user='ftpuser1', passwd='testpass') return ftp ftps = connect()As soon as I try to run that, I get the following:
$ python3 ftp.py Traceback (most recent call last): File "/home/user/ftp.py", line 12, in <module> ftps = connect() File "/home/user/ftp.py", line 6, in connect ftp.auth() File "/usr/lib/python3.10/ftplib.py", line 753, in auth resp = self.voidcmd('AUTH TLS') File "/usr/lib/python3.10/ftplib.py", line 285, in voidcmd self.putcmd(cmd) File "/usr/lib/python3.10/ftplib.py", line 207, in putcmd self.putline(line) File "/usr/lib/python3.10/ftplib.py", line 202, in putline self.sock.sendall(line.encode(self.encoding)) AttributeError: 'NoneType' object has no attribute 'sendall'Any ideas where to start looking?
Thanks in advance!