久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

帶有 Python ftplib 的 FTPS - 需要會(huì)話重用

FTPS with Python ftplib - Session reuse required(帶有 Python ftplib 的 FTPS - 需要會(huì)話重用)
本文介紹了帶有 Python ftplib 的 FTPS - 需要會(huì)話重用的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

問(wèn)題描述

所以,我正在嘗試連接到 FTP 服務(wù)器以獲取目錄列表并下載文件.但是 prot_p() 函數(shù)之后的第一個(gè)命令引發(fā)了異常 - 從日志中產(chǎn)生這些錯(cuò)誤:

So, I am trying to connect to an FTP server to get directory listings and download files. But the first command after the prot_p() function is raising an exception - Producing these errors from the log:

*get* '150 Here comes the directory listing.
'
*resp* '150 Here comes the directory listing.'
*get* '522 SSL connection failed; session reuse required: see require_ssl_reuse
option in vsftpd.conf man page
'
*resp* '522 SSL connection failed; session reuse required: see require_ssl_reuse
 option in vsftpd.conf man page'
Traceback (most recent call last):
  File "C:	empdownload.py", line 29, in <module>
    files = ftps.dir()
  File "C:Python27libftplib.py", line 522, in dir
    self.retrlines(cmd, func)
  File "C:Python27libftplib.py", line 725, in retrlines
    return self.voidresp()
  File "C:Python27libftplib.py", line 224, in voidresp
    resp = self.getresp()
  File "C:Python27libftplib.py", line 219, in getresp
    raise error_perm, resp
ftplib.error_perm: 522 SSL connection failed; session reuse required: see requir
e_ssl_reuse option in vsftpd.conf man page

代碼如下:

from ftplib import FTP_TLS
import os
import socket

host = 'example.com'
port = 34567
user = 'user1'
passwd = 'pass123'
acct = 'Normal'

ftps = FTP_TLS()

ftps.set_debuglevel(2)

ftps.connect(host, port)

print(ftps.getwelcome())
print(ftps.sock)

ftps.auth()

ftps.login(user, passwd, acct)

ftps.set_pasv(True)
ftps.prot_p()

print('Current directory:')
print(ftps.pwd())
files = ftps.dir()

ftps.quit()

我想安全地執(zhí)行此操作,因此使用 FTP over TLS Explicit.我的想法是我可能需要操作 ftplib 引用的 Socket 類中的一些設(shè)置.更改服務(wù)器上的設(shè)置是不可能的.我已經(jīng)使用 FileZilla 客戶端成功測(cè)試了服務(wù)器,但舊版本的 WinSCP 引發(fā)了同樣的錯(cuò)誤 - 盡管升級(jí)到最新版本修復(fù)了它.

I want to do this securely, hence using FTP over TLS Explicit. I have the idea that I may need to manipulate some settings in the Socket class referenced by ftplib. Changing the settings on the server is not a possibility. I have tested the server successfully with FileZilla client, an older version of WinSCP was raising the same error - although an upgrade to the newest version fixed it.

有什么想法嗎?

推薦答案

現(xiàn)在可以通過(guò)這個(gè)類(FTP_TLS的后代)輕松修復(fù)Python 3.6+:

It can be now easily fixed for Python 3.6+ by this class (descendant of FTP_TLS):

class MyFTP_TLS(ftplib.FTP_TLS):
    """Explicit FTPS, with shared TLS session"""
    def ntransfercmd(self, cmd, rest=None):
        conn, size = ftplib.FTP.ntransfercmd(self, cmd, rest)
        if self._prot_p:
            conn = self.context.wrap_socket(conn,
                                            server_hostname=self.host,
                                            session=self.sock.session)  # this is the fix
        return conn, size

這篇關(guān)于帶有 Python ftplib 的 FTPS - 需要會(huì)話重用的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問(wèn)題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!

相關(guān)文檔推薦

Why I cannot make an insert to Python list?(為什么我不能插入 Python 列表?)
Insert a column at the beginning (leftmost end) of a DataFrame(在 DataFrame 的開頭(最左端)插入一列)
Python psycopg2 not inserting into postgresql table(Python psycopg2 沒有插入到 postgresql 表中)
list extend() to index, inserting list elements not only to the end(list extend() 索引,不僅將列表元素插入到末尾)
How to add element in Python to the end of list using list.insert?(如何使用 list.insert 將 Python 中的元素添加到列表末尾?)
TypeError: #39;float#39; object is not subscriptable(TypeError:“浮動(dòng)對(duì)象不可下標(biāo))
主站蜘蛛池模板: 欧美日韩少妇 | 一级毛片免费播放视频 | 四虎影视最新地址 | 中文字幕在线看片 | 福利片在线观看 | 亚洲一区二区欧美 | 久久久久一区 | 一区二区三区四区视频 | 国产做爰免费观看视频 | 成人免费在线视频 | 日本黄色录像 | 日韩精品网站 | 国产三级成人 | 国产丝袜视频 | 91丨porny丨成人蝌蚪 | 国产资源视频 | 欧美日韩国产在线观看 | 亚洲精品影院 | 欧美成人免费视频 | 成人深夜福利 | 999毛片 | 欧美性猛交一区二区三区精品 | 中文字幕在线观看一区二区三区 | 触手繁殖の地狱3d啪啪 | 五月激情综合 | 俺去俺来也在线www色官网 | www一区 | 精品视频在线播放 | 久久er99热精品一区二区 | 日本免费毛片 | 亚洲国产福利 | 久久性视频 | 亚洲黄色成人 | 国产精品一区一区三区 | 男女插插插视频 | 五月婷婷激情综合 | 久久久久久久国产精品 | 日韩欧美中文字幕在线观看 | 国产精品毛片一区二区在线看 | 久久久精品国产sm调教 | 色妞色视频一区二区三区四区 |