X509ClientCertificateAuthentication.CustomCertificateValidator 属性

定义

获取或设置自定义客户端证书验证程序。

public:
 property System::IdentityModel::Selectors::X509CertificateValidator ^ CustomCertificateValidator { System::IdentityModel::Selectors::X509CertificateValidator ^ get(); void set(System::IdentityModel::Selectors::X509CertificateValidator ^ value); };
public System.IdentityModel.Selectors.X509CertificateValidator CustomCertificateValidator { get; set; }
member this.CustomCertificateValidator : System.IdentityModel.Selectors.X509CertificateValidator with get, set
Public Property CustomCertificateValidator As X509CertificateValidator

属性值

自定义客户端证书验证程序。

例外

在凭据为只读时进行设置。set

示例

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

// Create a service host.
Uri httpUri = new Uri("http://localhost/Calculator");
ServiceHost sh = new ServiceHost(typeof(Calculator), httpUri);

// Get a reference to the authentication object.
X509ClientCertificateAuthentication myAuthProperties =
    sh.Credentials.ClientCertificate.Authentication;

// Configure custom certificate validation.
myAuthProperties.CertificateValidationMode =
    X509CertificateValidationMode.Custom;
// Specify a custom certificate validator (not shown here) that inherits
// from the X509CertificateValidator class.
// creds.ClientCertificate.Authentication.CustomCertificateValidator =
//    new MyCertificateValidator();
' Create a service host.
Dim httpUri As New Uri("http://localhost/Calculator")
Dim sh As New ServiceHost(GetType(Calculator), httpUri)

' Get a reference to the authentication object.
Dim myAuthProperties As X509ClientCertificateAuthentication = _
sh.Credentials.ClientCertificate.Authentication

' Configure custom certificate validation.
myAuthProperties.CertificateValidationMode = X509CertificateValidationMode.Custom
' Specify a custom certificate validator (not shown here) that inherits 
' from the X509CertificateValidator class.
' creds.ClientCertificate.Authentication.CustomCertificateValidator = _
'    new MyCertificateValidator()

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

<serviceCredentials>  
  <clientCertificate>  
     <authentication certificateValidationMode='Custom' customCertificateValidatorType='Samples.MyCertificateValidator, Samples' />  
  </clientCertificate>  
</serviceCredentials>  

注解

如果 CertificateValidationMode 属性设置为 Custom,则必须将 CustomCertificateValidator 属性设置为从 X509CertificateValidator 类继承的自定义验证程序。

有关详细信息,请参见如何:创建使用自定义证书验证程序的服务

适用于

另请参阅