I would like to download a file using VB.NET (preferably) or C# via HTTPS.
I have this code to download a file over plain HTTP:
Dim client As WebClie
You need to add a certificate validator:
// You need to call it only once in a static constructor or multiple times there is no problem
ServicePointManager.ServerCertificateValidationCallback = ValidateCertificate;
private static bool ValidateCertificate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true;
}
In VB:
ServicePointManager.ServerCertificateValidationCallback = AddressOf ValidateCertificate
Dim client As WebClient = New WebClient()
'...
'Your code
Private Shared Function ValidateCertificate(sender As Object, certificate As X509Certificate, chain As X509Chain, sslPolicyErrors As SslPolicyErrors) As Boolean
return True
End Function