Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
in FAQ: edtFTPnet/PRO by (158k points)
closed by
How to download using HTTPS?
closed with the note: Answered

1 Answer

0 votes
by (20.4k points)
Best answer

To download using HTTPS, the machine needs to have the HTTPS certificate in its trusted store. If it is not (e.g. it is a self signed certificate), you will get an error like "Could not establish trust relationship for the SSL/TLS secure channel".

Currently, to deal with this the certificate needs to be imported into the trusted store, or validation needs to be bypassed.

This can be done as follows, using the ServerCertificateValidationCallback.

using System.Net;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

                += new RemoteCertificateValidationCallback(BypassSslCertificateValidation);

ftpConnection.Protocol = FileTransferProtocol.HTTP;
ftpConnection.UserName = "javaftp";
ftpConnection.Password = "javaftp";
ftpConnection.ServerAddress = "https://myurl";
ftpConnection.DownloadFile("d:\\tmp\\myfile.pdf", "https://myurl/myfile.pdf");

private static bool BypassSslCertificateValidation(
     object sender, X509Certificate cert, X509Chain chain, SslPolicyErrors error)
      return true;