英文:
Using WebClient.UploadFile with TLS (1.1 or 1.2)
问题
只想知道WebClient.UploadFile
是否通过1.1或1.2来进行TLS安全传输。我找到了以下代码行并已安装在我的应用程序中。
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
以下代码行在我的应用程序中工作。
WebClient.UploadFile("ftp://xxx.xxxx.xxx/xxxx/xxxx/" + Path.GetFileName(file), file);
这里有没有测试安全性的方法?
英文:
Just wondering if WebClient.Uploadfile
is TLS secure either by 1.1 or 1.2. I found the following line of code and have installed in my application.
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
The following line of code does the work in my application
WebClient.UploadFile("ftp://xxx.xxxx.xxx/xxxx/xxxx/" + Path.GetFileName(file), file);
Is there any way to test for security here?
答案1
得分: 1
你可以使用优秀的 WinSCP 库(程序集源代码)来建立安全的FTP连接:
using var session = new Session();
session.Open(new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "ftp.example.com",
UserName = "username",
Password = "password",
FtpSecure = FtpSecure.Explicit,
TlsHostCertificateFingerprint = "xx:xx:xx:..."
});
session.PutFiles("本地路径", "远程路径").Check();
你可以通过 FtpSecure
设置TLS是否应该是显式或隐式的。隐式TLS需要不同的端口,而显式TLS允许在同一端口上使用非安全和安全连接。
英文:
You can use nice WinSCP library (assemblies source) for secure FTP connection:
using var session = new Session();
session.Open(new SessionOptions
{
Protocol = Protocol.Ftp,
HostName = "ftp.example.com",
UserName = "username",
Password = "password",
FtpSecure = FtpSecure.Explicit,
TlsHostCertificateFingerprint = "xx:xx:xx:...",
});
session.PutFiles("local path", "remote path").Check();
You can set by FtpSecure
, if TLS should be explicit or implicit. Implicit TLS requires different port, while explicit TLS gives possibility to use the same port for unsecure and secure connection.
答案2
得分: 0
WebClient.UploadFile
不安全。设置 ServicePointManager.SecurityProtocol
不会改变这一点。
请参阅 https://stackoverflow.com/q/4331665/850848。
英文:
WebClient.UploadFile
is not secure. Setting ServicePointManager.SecurityProtocol
does not change anything about it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论