Powershell FTPWebRequest和EnableSsl = True
问题描述:
我搜索了这个网站,并通过Powershell找到了一个FTPWebRequest示例。我把它使用,它工作正常。但是,当我通过EnableSsl = $ True启用SSL时,我所得到的只是超时或延迟的“227进入被动模式”,这会打破进程。只要我禁用EnableSsl,我就可以直接通过。有人能指引我朝着正确的方向吗? FTP主机支持SSL。Powershell FTPWebRequest和EnableSsl = True
我最终想要将方法更改为DownloadFile并在代码下载文件后循环查找匹配项。不过,我想安全地做。
# Create an FTPWebRequest object to handle the connection to the FTP server
$ftprequest = [System.Net.FtpWebRequest]::Create($sourceuri)
# Set the request's network credentials for an authenticated connection
$ftprequest.Credentials = New-Object System.Net.NetworkCredential($username,$password)
# Set FTPWebRequest method to ListDirectory
$ftprequest.Method = [System.Net.WebRequestMethods+Ftp]::ListDirectory
$ftprequest.EnableSsl = $True
$ftprequest.UseBinary = $False
$ftprequest.UsePassive = $True
$ftprequest.KeepAlive = $False
$ftpresponse = $ftprequest.GetResponse()
Write-Out $ftpresponse.StatusCode
Write-Out $ftpresponse.StatusDescription
答
来发现,自发性问题是服务器端。