I'm trying to do a FTP TLS with python 3.6.2 on windows. Follows the code:
import ftplib
ftp = ftplib.FTP_TLS()
ftp.connect(host, port)
ftp.login(usr, pwd)
ftp.prot_p()
fh = open(r'C:\\Users\\AlexandreMagno\\Desktop\\teste2.txt', 'rb')
ftp.storbinary('STOR teste2.txt', fh)
fh.close()
But something gets wrong, I guess it's about the server certification. although even return error, the file is sent to the server.
Traceback (most recent call last):
File "D:/Google Drive/_ALEXANDRE/_ESTUDO/_PHYTON/_Códigos/FTP GESMAN/FTP GESMAN.py", line 26, in <module>
ftp.storbinary('STOR teste2.txt', fh)
File "C:\Program Files\Anaconda3\lib\ftplib.py", line 502, in storbinary
with self.transfercmd(cmd, rest) as conn:
File "C:\Program Files\Anaconda3\lib\ftplib.py", line 397, in transfercmd
return self.ntransfercmd(cmd, rest)[0]
File "C:\Program Files\Anaconda3\lib\ftplib.py", line 799, in ntransfercmd
server_hostname=self.host)
File "C:\Program Files\Anaconda3\lib\ssl.py", line 401, in wrap_socket
_context=self, _session=session)
File "C:\Program Files\Anaconda3\lib\ssl.py", line 808, in __init__
self.do_handshake()
File "C:\Program Files\Anaconda3\lib\ssl.py", line 1061, in do_handshake
self._sslobj.do_handshake()
File "C:\Program Files\Anaconda3\lib\ssl.py", line 683, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:749)
Using FileZilla works just fine, but before connecting, pops up a msg about certification and after acceptance connects, that reads:
Unknown certificate
The server's certificate is unknown. Please carefully examine the certificate to make sure the server can be trusted.