0

我需要从我的隐式 ftps 服务器下载一个 zip 文件。这是我尝试下载文件的代码:

import sys
import chilkat

ftp = chilkat.CkFtp2()

#  Any string unlocks the component for the 1st 30-days.
success = ftp.UnlockComponent("Anything for 30-day trial")
if (success != True):
    print(ftp.lastErrorText())
    sys.exit()

#  If this example does not work, try using passive mode
#  by setting this to True.
ftp.put_Passive(False)
ftp.put_Hostname("hostip")
ftp.put_Username("username")
ftp.put_Password("password")
ftp.put_Port(990)

#  We don't want AUTH SSL:
ftp.put_AuthTls(False)

#  We want Implicit SSL:
ftp.put_Ssl(True)

#  Connect and login to the FTP server.
success = ftp.Connect()
if (success != True):
    print(ftp.lastErrorText())
    sys.exit()
else:
    #  LastErrorText contains information even when
    #  successful. This allows you to visually verify
    #  that the secure connection actually occurred.
    print(ftp.lastErrorText())

print("FTPS Channel Established!")

#clearing the control channel
success = ftp.ClearControlChannel()
if (success != True):
    print(ftp.lastErrorText())
    sys.exit()
else:
    print(ftp.lastErrorText())
ftpResponse = ftp.feat()
fileSize = ftp.GetSizeByName("15_20.zip")
if (fileSize < 0):
    print("file does not exist")
else:
    print("file exists and is " + str(fileSize) + " bytes in size")

ftp.put_RestartNext(True)
localFilename = "C://mcx5min//14_40.zip" # copy the path from the old mcx.py
remoteFilename = "14_40.zip"
success = ftp.GetFile(remoteFilename, localFilename)
if (success != True):
    print(ftp.lastErrorText())
    sys.exit()
ftp.Disconnect()

在这个程序中,我能够登录到我的 ftps 服务器,并且还能够找到其中存在的文件。但是当我尝试通过GetFile()函数下载文件时,它会抛出类似“ 426 data connection closed, SSL/TLS negotiation failed”的错误。我不确切知道在本地使用 Windows 服务器时出现的错误是什么。我对此真的很陌生。所以请任何人帮助我解决这个问题。

4

0 回答 0