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