Muokkaa

Jaa


X509CertificateInitiatorServiceCredential.SetCertificate Method

Definition

Sets the certificate to use to encrypt messages sent to the client by the service. This setting is used only by bindings that are configured with the MutualCertificateDuplex message security authentication mode.

Overloads

SetCertificate(String, StoreLocation, StoreName)

Enables you to specify the certificate to use for encrypting messages for the client by specifying the subject distinguished name. This setting is used only by bindings that are configured with the MutualCertificateDuplex message security authentication mode.

SetCertificate(StoreLocation, StoreName, X509FindType, Object)

Specifies the certificate to use for encrypting messages for the client. This setting is used only by bindings that are configured with the MutualCertificateDuplex message security authentication mode.

SetCertificate(String, StoreLocation, StoreName)

Enables you to specify the certificate to use for encrypting messages for the client by specifying the subject distinguished name. This setting is used only by bindings that are configured with the MutualCertificateDuplex message security authentication mode.

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)

Parameters

subjectName
String

The subject distinguished name.

storeLocation
StoreLocation

The location of the certificate store that the service uses to obtain the certificate.

storeName
StoreName

The name of the X.509 certificate store to open.

Examples

The following code shows how to use this method to set the certificate.

Remarks

For more information about the subjectName parameter, see SubjectName.

Values for storeLocation are included in the StoreLocation enumeration:

  • LocalMachine: the certificate store assigned to the local machine (default).

  • CurrentUser: the certificate store used by the current user.

If the client application is running under a system account, then the certificate is typically in LocalMachine. If the client application is running under a user account, then the certificate is typically in CurrentUser.

Values for storeName are included in the StoreName enumeration.

Applies to

SetCertificate(StoreLocation, StoreName, X509FindType, Object)

Specifies the certificate to use for encrypting messages for the client. This setting is used only by bindings that are configured with the MutualCertificateDuplex message security authentication mode.

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)

Parameters

storeLocation
StoreLocation

The location of the certificate store that the service uses to obtain the certificate.

storeName
StoreName

The name of the X.509 certificate store to open.

findType
X509FindType

The type of X.509 search to be executed.

findValue
Object

The value to search for in the X.509 certificate store.

Examples

The following code shows how to use this method to set the certificate.

Remarks

Values for storeLocation are included in the StoreLocation enumeration:

  • LocalMachine: the certificate store assigned to the local machine (default).

  • CurrentUser: the certificate store used by the current user.

If the application is running under a system account, then the certificate is typically in LocalMachine. If the application is running under a user account, then the certificate is typically in CurrentUser.

Values for storeName are included in the StoreName enumeration.

Values for findType are included in the X509FindType enumeration.

The most commonly used enumeration is FindBySubjectName, which does a case-insensitive search on the subject name of certificates in the specified store. This can be an imprecise search. If no certificates or multiple certificates that match the criteria are found, an InvalidOperationException is thrown.

Applies to