Share via


X509ClientCertificateAuthentication.CustomCertificateValidator Vlastnost

Definice

Získá nebo nastaví validátor vlastního klientského certifikátu.

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

Hodnota vlastnosti

Validátor vlastních klientských certifikátů.

Výjimky

set pokud jsou přihlašovací údaje jen pro čtení.

Příklady

Následující kód ukazuje, jak tuto vlastnost nastavit.

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

Vlastnost lze také nastavit v konfiguračním souboru.

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

Poznámky

CertificateValidationMode Pokud je vlastnost nastavena na Custom, musíte vlastnost nastavit CustomCertificateValidator na vlastní validátor, který dědí z X509CertificateValidator třídy.

Další informace najdete v tématu Postupy: Vytvoření služby, která využívá vlastní validátor certifikátů.

Platí pro

Viz také