FtpWebRequest EnableSsl = true错误'根据验证过程,远程证书无效3

时间:2019-11-12 23:01:40

标签: c# .net-core ftpwebrequest

我尝试通过激活Enabled选项ssl = true来通过ftpwebrequest类通过ssl连接到ftp服务器

  

根据验证过程,远程证书无效。

这是我的密码

public void Upload(string container, string fileName, byte[] b)
        {
            Uri fullUri = new Uri(string.Format(@"{0}/{1}/{2}", Host, container, fileName));
            FtpWebRequest ftps = (FtpWebRequest)FtpWebRequest.Create(fullUri);
            ftps.Credentials = GetCredentials();

            ftps.KeepAlive = false;
            ftps.Method = WebRequestMethods.Ftp.UploadFile;
            ftps.UseBinary = true;
            ftps.EnableSsl = Ssl;
            ftps.ContentLength = b.Length;
            using (Stream StreamRequest = ftps.GetRequestStream())
            {
                StreamRequest.Write(b, 0, b.Length);
                StreamRequest.Close();
            }
        }

我已经看到,在某些出版物中,他们使用诸如

ServicePointManager.ServerCertificateValidationCallback = delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };

但是我不知道它的正确性或是否必须获得证书并给予类似的验证

0 个答案:

没有答案