X509ClientCertificateAuthentication 类
定义
指定身份验证属性以验证客户端证书。Specifies authentication properties for validating the client certificate.
public ref class X509ClientCertificateAuthentication
public class X509ClientCertificateAuthentication
type X509ClientCertificateAuthentication = class
Public Class X509ClientCertificateAuthentication
- 继承
-
X509ClientCertificateAuthentication
示例
下面的代码演示如何设置此属性。The following code shows how to set this property.
// 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 peer trust.
myAuthProperties.CertificateValidationMode =
X509CertificateValidationMode.PeerTrust;
// Configure chain trust.
myAuthProperties.CertificateValidationMode =
X509CertificateValidationMode.ChainTrust;
// 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 peer trust.
myAuthProperties.CertificateValidationMode = X509CertificateValidationMode.PeerTrust
' Configure chain trust.
myAuthProperties.CertificateValidationMode = X509CertificateValidationMode.ChainTrust
' 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()
该属性也可以在配置文件中设置。The property can also be set in a configuration file.
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode='ChainTrust' />
</clientCertificate>
</serviceCredentials>
注解
如果 CertificateValidationMode 设置为 Custom,则您必须创建从 X509CertificateValidator 类继承的自定义证书验证程序。If the CertificateValidationMode is set to Custom, then you must create a custom certificate validator that inherits from the X509CertificateValidator class. 有关详细信息,请参阅 如何:创建使用自定义证书验证程序的服务。For more information, see How to: Create a Service that Employs a Custom Certificate Validator.
属性
| CertificateValidationMode |
获取或设置证书验证模式。Gets or sets the certificate validation mode. |
| CustomCertificateValidator |
获取或设置自定义客户端证书验证程序。Gets or sets a custom client certificate validator. |
| IncludeWindowsGroups |
获取或设置一个值,该值指示 Windows 组是否包括在授权上下文中。Gets or sets a value that indicates whether Windows groups are included in the authorization context. |
| MapClientCertificateToWindowsAccount |
获取或设置一个值,该值指示是否将证书映射到 Windows 帐户。Gets or sets a value that indicates whether the certificate is mapped to Windows accounts. |
| RevocationMode |
获取或设置 ChainTrust 和 PeerOrChainTrust X.509 证书验证的证书吊销模式。Gets or sets the certificate revocation mode for ChainTrust and PeerOrChainTrust X.509 certificate validation. |
| TrustedStoreLocation |
获取或设置受信任存储区的位置,该位置下的客户端证书链已验证。Gets or sets the trusted store location under which context the client certificate chain is validated. |
方法
| Equals(Object) |
确定指定对象是否等于当前对象。Determines whether the specified object is equal to the current object. (继承自 Object) |
| GetHashCode() |
作为默认哈希函数。Serves as the default hash function. (继承自 Object) |
| GetType() |
获取当前实例的 Type。Gets the Type of the current instance. (继承自 Object) |
| MemberwiseClone() |
创建当前 Object 的浅表副本。Creates a shallow copy of the current Object. (继承自 Object) |
| ToString() |
返回表示当前对象的字符串。Returns a string that represents the current object. (继承自 Object) |