Cyberactiva - webmaster tutorials, programming and videogames tricks

webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu webmaster menu
  

Download File from Https

Download File from Https
I tried to develop an application to download a file from an Https server.
My application was able to download a file from a regural Http server.

I used a WebProxy and i passed the NetworkCredential, but also it didn't
work like:-
Dim myProxy As New WebProxy("https://TheServername.com/", 443)

Also I used that way to create a class to accept all kinds of
certifications, and also it didn't work.

Public Class acceptAllCerts
Implements System.Net.ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
ByVal cert As X509Certificate, ByVal request As WebRequest, ByVal
problem As Integer) _
As Boolean Implements ICertificatePolicy.CheckValidationResult
Return True
End Function
End Class

The message I am receiving is "The ServicePointManager does not support
proxies of https scheme."

Does anyone have any idea how to solve this?
Does anyone have any valid script to download a file from a secured Https
server?
Actually it's part of my code.

I have this part on my code:-

Dim newUri As New Uri(proxyAddress)
myProxy.Address = newUri
ServicePointManager.CertificatePolicy = New acceptAllCerts
ServicePointManager.FindServicePoint(newUri)

The code stops at the following line

Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)

and I got the following error :-
"The ServicePointManager does not support proxies of https scheme."

So I am not sure what I am missing in my code :(

"Altaf Al-Amin Najwani" wrote:

> It seems all is ok from your code but To use this CertificatePolicy, you'll
> have to tell the ServicePointManager to use it:
> System.Net.ServicePointManager.CertificatePolicy = new
> TrustAllCertificatePolicy();
> This must be done (one time during the application life cycle) before making
> the call to your webservice.
>
> are you doing same? moreover are you adding certificate using
> ClientCertificates.Add method of the proxy class
> "Nader Shahin" wrote:
> > I tried to develop an application to download a file from an Https server.
> > My application was able to download a file from a regural Http server.
> >
> > I used a WebProxy and i passed the NetworkCredential, but also it didn't
> > work like:-
> > Dim myProxy As New WebProxy("https://TheServername.com/", 443)
> > Also I used that way to create a class to accept all kinds of
> > certifications, and also it didn't work.
> > Public Class acceptAllCerts
> > Implements System.Net.ICertificatePolicy
> > Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
> > ByVal cert As X509Certificate, ByVal request As WebRequest, ByVal
> > problem As Integer) _
> > As Boolean Implements ICertificatePolicy.CheckValidationResult
> > Return True
> > End Function
> > End Class
> > The message I am receiving is "The ServicePointManager does not support
> > proxies of https scheme."
> > Does anyone have any idea how to solve this?
> > Does anyone have any valid script to download a file from a secured Https
> > server?
try this code if you have not yet :)

code snippet

Public Class SSLFullTrustCertificatePolicy
Implements ICertificatePolicy

Public Function CheckValidationResult(ByVal srvPoint As
System.Net.ServicePoint, ByVal certificate As
System.Security.Cryptography.X509Certificates.X509Certificate, ByVal request
As System.Net.WebRequest, ByVal certificateProblem As Integer) As Boolean
Implements System.Net.ICertificatePolicy.CheckValidationResult
Return True
End Function
End Class


System.Net.ServicePointManager.CertificatePolicy = New
SSLFullTrustCertificatePolicy

-----------
"Nader Shahin" wrote:

> Actually it's part of my code.
>
> I have this part on my code:-
> Dim newUri As New Uri(proxyAddress)
> myProxy.Address = newUri
> ServicePointManager.CertificatePolicy = New acceptAllCerts
> ServicePointManager.FindServicePoint(newUri)
> The code stops at the following line
> Dim ws As HttpWebResponse = CType(wr.GetResponse(), HttpWebResponse)
> and I got the following error :-
> "The ServicePointManager does not support proxies of https scheme."
> So I am not sure what I am missing in my code :(
> "Altaf Al-Amin Najwani" wrote:
> > It seems all is ok from your code but To use this CertificatePolicy, you'll
> > have to tell the ServicePointManager to use it:
> > System.Net.ServicePointManager.CertificatePolicy = new
> > TrustAllCertificatePolicy();
> > This must be done (one time during the application life cycle) before making
> > the call to your webservice.
> >
> > are you doing same? moreover are you adding certificate using
> > ClientCertificates.Add method of the proxy class
> > "Nader Shahin" wrote:
> > > I tried to develop an application to download a file from an Https server.
> > > My application was able to download a file from a regural Http server.
> > >
> > > I used a WebProxy and i passed the NetworkCredential, but also it didn't
> > > work like:-
> > > Dim myProxy As New WebProxy("https://TheServername.com/", 443)
> > > Also I used that way to create a class to accept all kinds of
> > > certifications, and also it didn't work.
> > > Public Class acceptAllCerts
> > > Implements System.Net.ICertificatePolicy
> > > Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
> > > ByVal cert As X509Certificate, ByVal request As WebRequest, ByVal
> > > problem As Integer) _
> > > As Boolean Implements ICertificatePolicy.CheckValidationResult
> > > Return True
> > > End Function
> > > End Class
> > > The message I am receiving is "The ServicePointManager does not support
> > > proxies of https scheme."
> > > Does anyone have any idea how to solve this?
> > > Does anyone have any valid script to download a file from a secured Https
> > > server?
Hi Nader,

Have a look at this post

http://www.mcse.ms/message1265781.html

"Nader Shahin" wrote:

> I tried to develop an application to download a file from an Https server.
> My application was able to download a file from a regural Http server.
>
> I used a WebProxy and i passed the NetworkCredential, but also it didn't
> work like:-
> Dim myProxy As New WebProxy("https://TheServername.com/", 443)
> Also I used that way to create a class to accept all kinds of
> certifications, and also it didn't work.
> Public Class acceptAllCerts
> Implements System.Net.ICertificatePolicy
> Public Function CheckValidationResult(ByVal srvPoint As ServicePoint, _
> ByVal cert As X509Certificate, ByVal request As WebRequest, ByVal
> problem As Integer) _
> As Boolean Implements ICertificatePolicy.CheckValidationResult
> Return True
> End Function
> End Class
> The message I am receiving is "The ServicePointManager does not support
> proxies of https scheme."
> Does anyone have any idea how to solve this?
> Does anyone have any valid script to download a file from a secured Https
> server?
Register for freeMembers Area
Web MarketingLast Web Marketing
Web MarketingLast Programming Tips
Web MarketingLast News


Web Marketing Links and links exchange .