Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ServicePointManager.CertificatePolicy Property

NOTE: This API is now obsolete.

Gets or sets policy for server certificates.

Namespace:  System.Net
Assembly:  System (in System.dll)

public static function get CertificatePolicy () : ICertificatePolicy 
public static function set CertificatePolicy (value : ICertificatePolicy)

Property Value

Type: System.Net.ICertificatePolicy
An object that implements the ICertificatePolicy interface.

When the CertificatePolicy property is set to an ICertificatePolicy interface object, the ServicePointManager object uses the certificate policy defined in that instance instead of the default certificate policy.

The default certificate policy allows valid certificates and valid certificates that have expired.

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.

No code example is currently available or this language may not be supported.
ServicePointManager::CertificatePolicy = new MyCertificatePolicy();

       // Create the request and receive the response
       try
       {
       WebRequest* myRequest = WebRequest::Create(myUri);
       WebResponse* myResponse = myRequest->GetResponse();
       ProcessResponse(myResponse);
       myResponse->Close();
       }
       // Catch any exceptions
       catch(WebException* e)
       {
       if (e->Status == WebExceptionStatus::TrustFailure)
       {
       // Code for handling security certificate problems goes here.
       }
       // Other exception handling goes here
       }

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 1.1, 1.0
Obsolete (compiler warning) in 3.5
Obsolete (compiler warning) in 3.5 SP1
Obsolete (compiler warning) in 3.0
Obsolete (compiler warning) in 3.0 SP1
Obsolete (compiler warning) in 3.0 SP2
Obsolete (compiler warning) in 2.0
Obsolete (compiler warning) in 2.0 SP1
Obsolete (compiler warning) in 2.0 SP2

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft