G
Guest
I have this code in a web service:
m_webclient = New WebClient
Dim byteArray As Byte()
byteArray = m_webclient.DownloadData(url)
and this has worked for quite a while. But recently, my company added SSL to
the server and now, I get the error message, "Underlying connection was
closed. Unable to connec to remote server."
It seems as if SSL is the culprit. This code is executed from client
machines. I have the feeling I need to do something like
Dim mySP As ServicePoint =
ServicePointManager.FindServicePoint(url.ToString())
Dim policy As MyPolicy
ServicePointManager.CertificatePolicy() = New MyPolicy
(I know this code is wrong, but I'm hoping it's not too wrong. MyPolicy is
this class:
Public Class MyPolicy
Implements ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As
ServicePoint, _
ByVal cert As X509Certificate, ByVal request As
WebRequest, _
ByVal certificateProblem As Integer) _
As Boolean Implements
ICertificatePolicy.CheckValidationResult
'Return True to force the certificate to be accepted.
Return True
End Function
Public Function AcceptAllCertificatePolicy() As Boolean
Return True
End Function
End Class
====================
Any help is obviously gratefully and nearly eternally appreciated.
RON
m_webclient = New WebClient
Dim byteArray As Byte()
byteArray = m_webclient.DownloadData(url)
and this has worked for quite a while. But recently, my company added SSL to
the server and now, I get the error message, "Underlying connection was
closed. Unable to connec to remote server."
It seems as if SSL is the culprit. This code is executed from client
machines. I have the feeling I need to do something like
Dim mySP As ServicePoint =
ServicePointManager.FindServicePoint(url.ToString())
Dim policy As MyPolicy
ServicePointManager.CertificatePolicy() = New MyPolicy
(I know this code is wrong, but I'm hoping it's not too wrong. MyPolicy is
this class:
Public Class MyPolicy
Implements ICertificatePolicy
Public Function CheckValidationResult(ByVal srvPoint As
ServicePoint, _
ByVal cert As X509Certificate, ByVal request As
WebRequest, _
ByVal certificateProblem As Integer) _
As Boolean Implements
ICertificatePolicy.CheckValidationResult
'Return True to force the certificate to be accepted.
Return True
End Function
Public Function AcceptAllCertificatePolicy() As Boolean
Return True
End Function
End Class
====================
Any help is obviously gratefully and nearly eternally appreciated.
RON