ClientCredentials.ClientCertificate 属性

定义

获取一个对象,您可以使用该对象来提供客户端用于通过到服务的验证的 X.509 证书。Gets an object that you can use to provide the X.509 certificate that the client uses to authenticate to the service.

public:
 property System::ServiceModel::Security::X509CertificateInitiatorClientCredential ^ ClientCertificate { System::ServiceModel::Security::X509CertificateInitiatorClientCredential ^ get(); };
public System.ServiceModel.Security.X509CertificateInitiatorClientCredential ClientCertificate { get; }
member this.ClientCertificate : System.ServiceModel.Security.X509CertificateInitiatorClientCredential
Public ReadOnly Property ClientCertificate As X509CertificateInitiatorClientCredential

属性值

X509CertificateInitiatorClientCredential

一个表示客户端证书的 X509CertificateInitiatorClientCredentialAn X509CertificateInitiatorClientCredential that represents the client certificate.

示例

下面的代码演示如何使用此属性配置 X.509 证书。The following code shows how you can use this property to configure the X.509 certificate.

// Create the client with the binding and EndpointAddress.
CalculatorClient calcClient = new CalculatorClient(b, ea);

// Set the client credential value to a valid certificate.
calcClient.ClientCredentials.ClientCertificate.SetCertificate(
    StoreLocation.CurrentUser,
    StoreName.TrustedPeople,
    X509FindType.FindBySubjectName,
    "client.com");
' Create the client with the binding and EndpointAddress.
Dim calcClient As New CalculatorClient(b, ea)

' Set the client credential value to a valid certificate.
calcClient.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.TrustedPeople, X509FindType.FindBySubjectName, "client.com")

注解

你还可以在客户端应用程序配置文件中使用 < 证书 > 来设置此值。You can also set this value using the <certificate> in a client application configuration file.

适用于