Share via


X509CertificateInitiatorClientCredential.SetCertificate Yöntem

Tanım

Hizmeti temsil etmek için kullanılacak sertifikayı belirtir.

Aşırı Yüklemeler

SetCertificate(String, StoreLocation, StoreName)

Konu ayırt edici adını belirterek hizmeti temsil etmek için kullanılacak sertifikayı belirtmenize olanak tanır.

SetCertificate(StoreLocation, StoreName, X509FindType, Object)

, storeNameve findValuegibi storeLocationsorgu parametrelerini belirterek istemciyi temsil etmek için kullanılacak sertifikayı belirtmenize findType olanak tanır.

SetCertificate(String, StoreLocation, StoreName)

Kaynak:
X509CertificateInitiatorClientCredential.cs
Kaynak:
X509CertificateInitiatorClientCredential.cs
Kaynak:
X509CertificateInitiatorClientCredential.cs

Konu ayırt edici adını belirterek hizmeti temsil etmek için kullanılacak sertifikayı belirtmenize olanak tanır.

public:
 void SetCertificate(System::String ^ subjectName, System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName);
public void SetCertificate (string subjectName, System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName);
member this.SetCertificate : string * System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName -> unit
Public Sub SetCertificate (subjectName As String, storeLocation As StoreLocation, storeName As StoreName)

Parametreler

subjectName
String

Konu ayırt edici adı.

storeLocation
StoreLocation

Hizmetin hizmet sertifikasını almak için kullandığı sertifika deposunun konumu.

storeName
StoreName

Açılacak X.509 sertifika deposunun adını belirtir.

Örnekler

Aşağıdaki kod kullanılacak sertifikayı belirtir.

// Create a WSHttpBinding and set its security properties. The
// security mode is Message, and the client is authenticated with
// a certificate.
EndpointAddress ea = new EndpointAddress("http://contoso.com/");
WSHttpBinding b = new WSHttpBinding();
b.Security.Mode = SecurityMode.Message;
b.Security.Message.ClientCredentialType =
    MessageCredentialType.Certificate;

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

// Set the client credential value to a valid certificate.
cc.ClientCredentials.ClientCertificate.SetCertificate(
    "CN=MyName, OU=MyOrgUnit, C=US",
    StoreLocation.CurrentUser,
    StoreName.TrustedPeople);

Açıklamalar

parametresi hakkında subjectName daha fazla bilgi için bkz SubjectName. .

değerleri storeLocation numaralandırmaya StoreLocation eklenir:

  • LocalMachine: yerel makineye atanan sertifika deposu (varsayılan).

  • CurrentUser: geçerli kullanıcı tarafından kullanılan sertifika deposu.

İstemci uygulaması bir sistem hesabı altında çalışıyorsa, sertifika genellikle içindedir LocalMachine. İstemci uygulaması bir kullanıcı hesabı altında çalışıyorsa, sertifika genellikle içinde CurrentUserolur.

değerleri storeName sabit listesi içinde StoreName yer alır.

Şunlara uygulanır

SetCertificate(StoreLocation, StoreName, X509FindType, Object)

Kaynak:
X509CertificateInitiatorClientCredential.cs
Kaynak:
X509CertificateInitiatorClientCredential.cs
Kaynak:
X509CertificateInitiatorClientCredential.cs

, storeNameve findValuegibi storeLocationsorgu parametrelerini belirterek istemciyi temsil etmek için kullanılacak sertifikayı belirtmenize findType olanak tanır.

public:
 void SetCertificate(System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName, System::Security::Cryptography::X509Certificates::X509FindType findType, System::Object ^ findValue);
public void SetCertificate (System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName, System.Security.Cryptography.X509Certificates.X509FindType findType, object findValue);
member this.SetCertificate : System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName * System.Security.Cryptography.X509Certificates.X509FindType * obj -> unit
Public Sub SetCertificate (storeLocation As StoreLocation, storeName As StoreName, findType As X509FindType, findValue As Object)

Parametreler

storeLocation
StoreLocation

İstemcinin istemci sertifikasını almak için kullandığı sertifika deposunun konumu.

storeName
StoreName

Açılacak X.509 sertifika deposunun adını belirtir.

findType
X509FindType

Yürütülecek X.509 aramasının türünü tanımlar.

findValue
Object

X.509 sertifika deposunda aranacak değer.

Örnekler

Aşağıdaki kod kullanılacak sertifikayı belirtir.

// Create a WSHttpBinding and set its security properties. The
// security mode is Message, and the client is authenticated with
// a certificate.
EndpointAddress ea = new EndpointAddress("http://contoso.com/");
WSHttpBinding b = new WSHttpBinding();
b.Security.Mode = SecurityMode.Message;
b.Security.Message.ClientCredentialType =
    MessageCredentialType.Certificate;

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

// Set the client credential value to a valid certificate.
cc.ClientCredentials.ClientCertificate.SetCertificate(
    StoreLocation.CurrentUser,
    StoreName.TrustedPeople,
    X509FindType.FindBySubjectName,
    "client.com");
' Create a WSHttpBinding and set its security properties. The
' security mode is Message, and the client is authenticated with 
' a certificate.
Dim ea As New EndpointAddress("http://contoso.com/")
Dim b As New WSHttpBinding()
b.Security.Mode = SecurityMode.Message
b.Security.Message.ClientCredentialType = MessageCredentialType.Certificate

' Create the client with the binding and EndpointAddress.
Dim cc As New CalculatorClient(b, ea)

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

Açıklamalar

değerleri storeLocation numaralandırmaya StoreLocation eklenir:

  • LocalMachine: yerel makineye atanan sertifika deposu (varsayılan).

  • CurrentUser: geçerli kullanıcı tarafından kullanılan sertifika deposu.

İstemci uygulaması bir sistem hesabı altında çalışıyorsa, sertifika genellikle içindedir LocalMachine. İstemci uygulaması bir kullanıcı hesabı altında çalışıyorsa, sertifika genellikle içinde CurrentUserolur.

değerleri storeName sabit listesi içinde StoreName yer alır.

değerleri findType sabit listesi içinde X509FindType yer alır.

En yaygın olarak kullanılan numaralandırma, belirtilen depodaki sertifikaların konu adı üzerinde büyük/küçük harfe duyarlı olmayan bir arama yapan numaralandırmadır FindBySubjectName. Bu, kesin olmayan bir arama olabilir. Birden fazla sertifika döndürülürse, istemciyi temsil etmek için bul ile eşleşen ilk sertifika kullanılır.

Şunlara uygulanır