Я пытаюсь аутентифицировать File Zila Certificate в своем коде C #, но выдает ошибку
"System.Security.Cryptography.CryptographicException:« Не удается найти запрошенный объект »
Может кто-нибудь сказать мне, что не так с кодом?
private static String Get_Data_From_FTP_Server_File()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
//used to display data into rich text.box
String result = String.Empty;
FtpWebRequest reqFTP = (FtpWebRequest)WebRequest.Create("ftp://ftpdemo03.eastus.cloudapp.azure.com:21/STAGING/");
reqFTP.Method = WebRequestMethods.Ftp.ListDirectory;
//Enable SSL
reqFTP.EnableSsl = true;
ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => tru
X509Certificate cert = X509Certificate.CreateFromCertFile(@"C:\certificate\my_certificate.crt");
X509CertificateCollection certCollection = new X509CertificateCollection();
certCollection.Add(cert);
reqFTP.ClientCertificates = certCollection;
//set up credentials.
reqFTP.Credentials = new NetworkCredential("Testuser", "11111");
//initialize Ftp response.
FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse();
//open readers to read data from ftp
Stream responsestream = response.GetResponseStream();
StreamReader reader = new StreamReader(responsestream);
//read data from FTP
result = reader.ReadToEnd();
//save file locally on your pc
using (StreamWriter file = File.CreateText("states.txt"))
{
file.WriteLine(result);
file.Close();
}
//close readers.
reader.Close();
response.Close();
//return data from file.
return result;
}
}
Моя цель - получить файлы из Filezila путем проверки сертификата.