使用SSL连接建立FTP

编程入门 行业动态 更新时间:2024-10-25 00:32:55
本文介绍了使用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()

解决方案

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

你应该问一下一般论坛或库论坛, 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 library forum, does the 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

本文发布于:2023-11-15 04:43:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1591247.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SSL   FTP

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!