G
Guest
I have been looking all over the web for an example of how to accomplish this. I am trying to download a comma seperated file from a https server. I can't establish the connection - the error reads
System.Net.WebException: The underlying connection was closed: Could not establish secure channel for SSL/TLS. ---> System.ComponentModel.Win32Exception: The function completed successfully, but must be called again to complete the contex
Here is the code to execute the file download
NetworkCredential cred = new NetworkCredential("user", "pass")
ServicePointManager.CertificatePolicy = new CertPolicy()
tr
WebRequest request = WebRequest.Create("https://securesite.com/file.csv")
request.Credentials = cred
WebResponse response = request.GetResponse()
Stream stream = response.GetResponseStream()
StreamReader reader = null
reader = new StreamReader(stream)
catch (Exception ex
this.txtError.Text = ex.ToString()
class CertPolicy: ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
{
return true;
}
}
Any help on this would greatly be appreciated. Also - any books that anyone could reccommend on this type of programming would be appreciated
Thanks - Drew
System.Net.WebException: The underlying connection was closed: Could not establish secure channel for SSL/TLS. ---> System.ComponentModel.Win32Exception: The function completed successfully, but must be called again to complete the contex
Here is the code to execute the file download
NetworkCredential cred = new NetworkCredential("user", "pass")
ServicePointManager.CertificatePolicy = new CertPolicy()
tr
WebRequest request = WebRequest.Create("https://securesite.com/file.csv")
request.Credentials = cred
WebResponse response = request.GetResponse()
Stream stream = response.GetResponseStream()
StreamReader reader = null
reader = new StreamReader(stream)
catch (Exception ex
this.txtError.Text = ex.ToString()
class CertPolicy: ICertificatePolicy
{
public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
{
return true;
}
}
Any help on this would greatly be appreciated. Also - any books that anyone could reccommend on this type of programming would be appreciated
Thanks - Drew