How can I download a file from a website that asks for a digital certificate?

0

I'm working in Visual Studio 2017, my question is how to get a file that can be found in a one page link but it requires a digital certificate. I have the certificate but I do not know how to enter with it and download the file.

Currently this is the code I have but I download the HTML of the page.

X509Certificate2 cer = ElegirCertificado();

using (var client = new MyWebClient(cer)) {
    client.DownloadFile("link de la pagina", @"D:\PruebaSw\Destino\jaja.csv");
}

public X509Certificate2 ElegirCertificado(){
    X509Store store = new X509Store(StoreLocation.CurrentUser);
    store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);
    X509Certificate2Collection certificates = store.Certificates;
    X509Certificate2Collection foundCertificates = certificates.Find(X509FindType.FindByTimeValid, DateTime.Now, false);
    var cert = foundCertificates.OfType<X509Certificate2>().First();
    return cert;
}
    
asked by Claudio Anticoi Ojeda 31.07.2018 в 16:43
source

0 answers