Gets or sets policy for server certificates.
Assembly: System (in System.dll)
<ObsoleteAttribute("CertificatePolicy is obsoleted for this type, please use ServerCertificateValidationCallback instead. http://go.microsoft.com/fwlink/?linkid=14202")> Public Shared Property CertificatePolicy As ICertificatePolicy
The following code example shows how to catch a certificate policy exception for a custom certificate policy. It assumes that the certificate policy object has been defined, that the Uniform Resource Identifier (URI) for the Web resource is contained in the variable myUri, and that there is a method named ProcessResponse that performs the work of the application.
ServicePointManager.CertificatePolicy = New MyCertificatePolicy() ' Create the request and receive the response Try Dim myRequest As WebRequest = WebRequest.Create(myUri) Dim myResponse As WebResponse = myRequest.GetResponse() ProcessResponse(myResponse) myResponse.Close() ' Catch any exceptions Catch e As WebException If e.Status = WebExceptionStatus.TrustFailure Then ' Code for handling security certificate problems goes here. End If ' Other exception handling goes here End Try
Available since 1.1