X509ServiceCertificateAuthentication.CertificateValidationMode 属性

定义

获取或设置证书验证模式。

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

属性值

X509CertificateValidationMode 中的枚举的一个值。

示例

下面的代码演示如何设置此属性。

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()

该属性也可以在配置文件中设置。

注解

此枚举捕获选项以确定使用 SSL/TLS 协商获取的服务证书的有效性。 有关枚举成员的列表,请参见 X509CertificateValidationMode

适用于