X509ClientCertificateAuthentication 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
指定身份验证属性以验证客户端证书。
public ref class X509ClientCertificateAuthentication
public class X509ClientCertificateAuthentication
type X509ClientCertificateAuthentication = class
Public Class X509ClientCertificateAuthentication
- 继承
-
X509ClientCertificateAuthentication
示例
下面的代码演示如何设置此属性。
// 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()
该属性也可以在配置文件中设置。
<serviceCredentials>
<clientCertificate>
<authentication certificateValidationMode='ChainTrust' />
</clientCertificate>
</serviceCredentials>
注解
如果 CertificateValidationMode 设置为 Custom,则您必须创建从 X509CertificateValidator 类继承的自定义证书验证程序。 有关详细信息,请参见如何:创建使用自定义证书验证程序的服务。
属性
CertificateValidationMode |
获取或设置证书验证模式。 |
CustomCertificateValidator |
获取或设置自定义客户端证书验证程序。 |
IncludeWindowsGroups |
获取或设置一个值,该值指示 Windows 组是否包括在授权上下文中。 |
MapClientCertificateToWindowsAccount |
获取或设置一个值,该值指示是否将证书映射到 Windows 帐户。 |
RevocationMode |
获取或设置 ChainTrust 和 PeerOrChainTrust X.509 证书验证的证书吊销模式。 |
TrustedStoreLocation |
获取或设置受信任存储区的位置,该位置下的客户端证书链已验证。 |
方法
Equals(Object) |
确定指定对象是否等于当前对象。 (继承自 Object) |
GetHashCode() |
作为默认哈希函数。 (继承自 Object) |
GetType() |
获取当前实例的 Type。 (继承自 Object) |
MemberwiseClone() |
创建当前 Object 的浅表副本。 (继承自 Object) |
ToString() |
返回表示当前对象的字符串。 (继承自 Object) |