【发布时间】:2018-11-15 13:38:17
【问题描述】:
我正在尝试使用FtpWebRequest 创建一个FTPRequest 以将报告文件发送到我的服务器。但我不了解 SSL/TLS 连接。
我使用的服务器接受 TLS 连接。那么,仅仅设置EnableSsl = true 就够了吗?还是我需要客户证书?
如果我只是将EnableSsl 设置为true,则接受连接并发送文件。
ftpRequest = (FtpWebRequest)WebRequest.Create(url);
ftpRequest.UseBinary = true;
ftpRequest.UsePassive = true;
ftpRequest.KeepAlive = false;
ftpRequest.Proxy = null;
ftpRequest.Credentials = new NetworkCredential(username, password);
如果我想要 TLS/SSL:
ftpRequest.EnableSsl = true;
X509Certificate cert = X509Certificate.CreateFromCertFile(filePath);
X509CertificateCollection certCollection = new X509CertificateCollection { cert };
ftpRequest.ClientCertificates = certCollection;
如果我设置了证书并尝试连接,服务器不会响应并且不会给我任何异常。
我真的需要证书吗?我不知道证书是否在连接上有所不同。证书的用途是什么?
谢谢
【问题讨论】:
标签: c# ftp client-certificates ftpwebrequest ftps