使用自定义端口号通过 SSL 发送文件 FTP
我想使用自定义端口号通过 ssl 上传和下载文件到 FTP 或使用隐式 SSL 的 FTP。 我正在使用 .net ftpwebrequest & ftpwebresponse 方法用于此目的。 这是我的代码:
Dim reqObj As FtpWebRequest = CType(WebRequest.Create(_Url + filename), FtpWebRequest)
reqObj.Method = WebRequestMethods.Ftp.UploadFile
reqObj.KeepAlive = False
If _IsSSLEnable Then
reqObj.UseBinary = True
End If
reqObj.Credentials = New NetworkCredential(_UserName, _Password)
If _IsSSLEnable Then
reqObj.EnableSsl = _IsSSLEnable Net.ServicePointManager.ServerCertificateValidationCallback = AddressOf validateCert
End If
Dim streamResponse As Stream
streamResponse = reqObj.GetRequestStream()
在此之后我收到错误...
服务器返回一个地址来响应 PASV 命令,该地址与建立 FTP 连接的地址不同。
但如果我添加
reqObj.UsePassive = False
它会给我错误:
操作超时
这对于普通 ftp 和 ssl 上的 ftp 来说工作正常,但对于自定义端口号或隐式 ssl 则不行。
你能告诉我 .net 支持吗?
或者我必须在这种情况下使用其他方法
谢谢,
Hemant
I want to upload and download a file to FTP over ssl with custom port number or FTP with implicit SSL.
I am using .net ftpwebrequest & ftpwebresponse method for this.
here is my code:
Dim reqObj As FtpWebRequest = CType(WebRequest.Create(_Url + filename), FtpWebRequest)
reqObj.Method = WebRequestMethods.Ftp.UploadFile
reqObj.KeepAlive = False
If _IsSSLEnable Then
reqObj.UseBinary = True
End If
reqObj.Credentials = New NetworkCredential(_UserName, _Password)
If _IsSSLEnable Then
reqObj.EnableSsl = _IsSSLEnable Net.ServicePointManager.ServerCertificateValidationCallback = AddressOf validateCert
End If
Dim streamResponse As Stream
streamResponse = reqObj.GetRequestStream()
I am getting error after this...
The server returned an address in response to the PASV command that is different than the address to which the FTP connection was made.
But if i Add
reqObj.UsePassive = False
It gives me error:
The operation has timed out
this is working fine for normal ftp and ftp over ssl but not for custom port number or implicit ssl.
Can you please tell me does .net support this?
Or I have to use other method for this case
Thanks,
Hemant
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SO 上已经有一个非常类似的问题: Set Port number when using FtpWebRequest在 C# 中,
解决方案看起来是这样的:
但请检查该问题和答案以获取更多详细信息。
there is a very similar question already on SO: Set Port number when using FtpWebRequest in C#
it looks like the solution was this:
but check that question and answer for more details.