与运行TLS-1.2的服务器交谈的客户端Python错误

时间:2019-12-12 06:53:29

标签: python ftp tls1.2

我的网络托管公司VentraIP最近将我使用的服务器从“不安全”升级了 到一个正在运行的TLS-1.2

这需要对相关脚本进行一些修改,新的脚本需要连接,然后进行更改 工作目录还可以。

库文件中的任何操作(例如目录列表)失败的问题。

测试程序

from ftplib  import FTP_TLS

# Establish TLS FTP Connection
ftp = FTP_TLS('servername')
ftp.debugging = 2
ftp.login(user = 'username', passwd = 'password')
ftp.prot_p()

# Change to To Relevant Public HTML Folder
ftp.cwd('public_html')
ftp.retrlines('LIST')

运行时间日志

>>> %Run ftp-tls.py
*cmd* 'AUTH TLS'
*put* 'AUTH TLS\r\n'
*get* '234 AUTH TLS OK.\n'
*resp* '234 AUTH TLS OK.'
*cmd* 'USER xxxxxx.com'
*put* 'USER xxxxxx.com\r\n'
*get* '331 User xxx@xxxxxx.com OK. Password required\n'
*resp* '331 User xxx@xxxxxx.com OK. Password required'
*cmd* 'PASS **********'
*put* 'PASS **********\r\n'
*get* '230 OK. Current restricted directory is /\n'
*resp* '230 OK. Current restricted directory is /'
*cmd* 'PBSZ 0'
*put* 'PBSZ 0\r\n'
*get* '200 PBSZ=0\n'
*resp* '200 PBSZ=0'
*cmd* 'PROT P'
*put* 'PROT P\r\n'
*get* '200 Data protection level set to "private"\n'
*resp* '200 Data protection level set to "private"'
*cmd* 'CWD public_html'
*put* 'CWD public_html\r\n'
*get* '250 OK. Current directory is /public_html\n'
*resp* '250 OK. Current directory is /public_html'
*cmd* 'TYPE A'
*put* 'TYPE A\r\n'
*get* '200 TYPE is now ASCII\n'
*resp* '200 TYPE is now ASCII'
*cmd* 'PASV'
*put* 'PASV\r\n'
*get* '227 Entering Passive Mode (103,27,34,41,239,196)\n'
*resp* '227 Entering Passive Mode (103,27,34,41,239,196)'
*cmd* 'LIST'
*put* 'LIST\r\n'
*get* '150 Accepted data connection\n'
*resp* '150 Accepted data connection'

Traceback (most recent call last):
  File "C:\Users\peter\ftp-tls.py", line 11, in <module>
    ftp.retrlines('LIST')
  File "C:\Users\peter\AppData\Local\Programs\Thonny\lib\ftplib.py", line 485, in retrlines
    conn.unwrap()
  File "C:\Users\peter\AppData\Local\Programs\Thonny\lib\ssl.py", line 1115, in unwrap
    s = self._sslobj.shutdown()
OSError: [Errno 0] Error
>>> 

测试脚本当前在Win 10上的Thonny 3.2.3-Python 3.7.5上运行


任何想法,例如我的python脚本,python库问题或服务器配置问题

谢谢

彼得

0 个答案:

没有答案