Επεξεργασία

Κοινή χρήση μέσω


X509ServiceCertificateAuthentication.CertificateValidationMode Property

Definition

Gets or sets the certificate validation mode.

public:
 property System::ServiceModel::Security::X509CertificateValidationMode CertificateValidationMode { System::ServiceModel::Security::X509CertificateValidationMode get(); void set(System::ServiceModel::Security::X509CertificateValidationMode value); };
public System.ServiceModel.Security.X509CertificateValidationMode CertificateValidationMode { get; set; }
member this.CertificateValidationMode : System.ServiceModel.Security.X509CertificateValidationMode with get, set
Public Property CertificateValidationMode As X509CertificateValidationMode

Property Value

A value from the enumeration in X509CertificateValidationMode.

Examples

The following code shows how to set this property.

ClientCredentials creds = new ClientCredentials();
// Configure peer trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode =
          X509CertificateValidationMode.PeerTrust;

// Configure chain trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode =
              X509CertificateValidationMode.ChainTrust;

// Configure custom certificate validation.
creds.ServiceCertificate.Authentication.CertificateValidationMode =
              X509CertificateValidationMode.Custom;
creds.ServiceCertificate.Authentication.CustomCertificateValidator =
    new MyCertificateValidator();
Dim creds As New ClientCredentials()
' Configure peer trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.PeerTrust

' Configure chain trust.
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.ChainTrust

' Configure custom certificate validation.
creds.ServiceCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.Custom
creds.ServiceCertificate.Authentication.CustomCertificateValidator = New MyCertificateValidator()

The property can also be set in a configuration file.

Remarks

This enumeration captures the options for determining the validity of the service certificate obtained using SSL/TLS negotiation. For a list of the enumeration members, see X509CertificateValidationMode.

Applies to