使用SSL连接建立FTP [英] Establish FTP with SSL Connection

查看:454
本文介绍了使用SSL连接建立FTP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我正在尝试使用带有自签名证书的FileZilla FTP服务器将文件上传到我的服务器。到目前为止,我已经能够绕过AuthorizationException错误,但如果我的Request.UsePassive是默认的,我会收到此错误:


 


远程服务器返回错误:227进入被动模式(192,168,1,13,194,158)




所以要解决我放入request.UsePassive = False,然而,现在导致应用程序冻结并且FTP服务器返回错误"425 Can "打开数据连接" 


默认端口被转发,防火墙暂时关闭,所以我不知道发生了什么。


这是我一直在使用的代码:


 
Dim request As System.Net.FtpWebRequest = DirectCast (System.Net.WebRequest.Create(" ftp://serveraddress/file.txt" ),System.Net.FtpWebRequest)
request.Credentials = System.Net.NetworkCredential("用户名" " password"
request.EnableSsl = True
request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
Dim file() As Byte = System.IO.File.ReadAllBytes( " c:\ file.txt"
ServicePointManager.ServerCertificateValidationCallback = 功能(sender1 作为 对象,证书作为 X509Certificate,链作为 X509Chain,sslPolicyErrors As SslPolic yErrors) True
request.UsePassive = False
Dim strz As System.IO.Stream = request.GetRequestStream()
strz.Write(file, 0,file.Length)
strz.Close()
strz.Dispose()

解决方案

< blockquote>

我不是网络技术方面的专家,但我所知道的是,FTP + SSL = FTP的扩展版本叫做FTPS。


你应该问一下一般论坛或.net库论坛,.net Framework是否支持它。我听说有更新版本的Windows支持它,但它更像是一个框架问题,而不是直接的Visual Basic问题。


So I'm trying to upload a file to my server using the FileZilla FTP Server with a self-signed certificate. So far I've been able to bypass the AuthorizationException error, but if my Request.UsePassive is default, I get this error:

 

The remote server returned an error: 227 Entering Passive Mode (192,168,1,13,194,158)


So to solve that I put in request.UsePassive = False, however, that now causes the application to freeze and the FTP server to return the error "425 Can't open data connection" 

Default ports are forwarded and firewall is temporarily turned off, so I have no idea what is going on.

Here is the code I've been using:

        Dim request As System.Net.FtpWebRequest = DirectCast(System.Net.WebRequest.Create("ftp://serveraddress/file.txt"), System.Net.FtpWebRequest)
        request.Credentials = New System.Net.NetworkCredential("username", "password")
        request.EnableSsl = True
        request.Method = System.Net.WebRequestMethods.Ftp.UploadFile
        Dim file() As Byte = System.IO.File.ReadAllBytes("c:\file.txt")
        ServicePointManager.ServerCertificateValidationCallback = Function(sender1 As Object, certificate As X509Certificate, chain As X509Chain, sslPolicyErrors As SslPolicyErrors) True
        request.UsePassive = False
        Dim strz As System.IO.Stream = request.GetRequestStream()
        strz.Write(file, 0, file.Length)
        strz.Close()
        strz.Dispose()

解决方案

I'm not an expert in network technologies, but what I know, is that FTP + SSL = an extended version of FTP called FTPS.

You should ask on the general forum or at the .net library forum, does the .net Framework support it. I have heard about newer versions of Windows supporting it, but it's more like a framework question than a direct Visual Basic question.


这篇关于使用SSL连接建立FTP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆