By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,333 Members | 1,070 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,333 IT Pros & Developers. It's quick & easy.

**Webclient and SSL**

P: n/a
Hi. I have a webserver which executes the following code:
m_webclient = New WebClient
Dim byteArray As Byte()
byteArray = m_webclient.DownloadData(url)

This actually retrieves an XML document which I parse.
This code works perfectly, up to now. However, we
recently installed SSL on the web server (a Unix box) and
while everything else works OK, when this code is
executed, I get "connection closed. Unable to establish a
connection." After some research, I discovered this was
due to the certificate. So, I wrote this code:

Private Class MyPolicy Implements ICertificatePolicy

Public Function CheckValidationResult(ByVal srvPoint As
ServicePoint, _
ByVal cert As X509Certificate, ByVal request As
WebRequest, _
ByVal certificateProblem As Integer) _
s Boolean Implements

'Return True to force the certificate to be accepted.
Return True
End Function
Public Function AcceptAllCertificatePolicy() As Boolean
Return True
End Function
End Class

and modified my webclient code this way:

ServicePointManager.CertificatePolicy() = New MyPolicy
m_webclient = New WebClient
Dim byteArray As Byte()
byteArray = m_webclient.DownloadData(url)

this works perfectly, but I don't understand why. That is
to say, if I change the return values of the functions
to 'false' this code still works (I can connect and
download). If I put breakpoints in the functions, they
don't get hit. does this work? I've searched the
web, to no avail.



Nov 21 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.