【问题标题】:Powershell FTPWebRequest and EnableSsl = TruePowershell FTPWebRequest 和 EnableSsl = True
【发布时间】:2009-08-14 17:15:22
【问题描述】:

我搜索了这个站点并通过 Powershell 找到了一个 FTPWebRequest 示例。我使用它,它工作正常。但是,当我通过 EnableSsl=$True 启用 SSL 时,我得到的只是超时或延迟的“227 进入被动模式”,这会中断进程。只要我禁用 EnableSsl,我就可以直接飞过去。有人可以指出我正确的方向吗? FTP 主机支持 SSL。

在获得列表并找到匹配项后,我最终希望将方法更改为 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

【问题讨论】:

    标签: powershell ftp ftpwebrequest


    【解决方案1】:

    来发现,自发的问题是服务器端的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-14
      相关资源
      最近更新 更多