X509CertificateInitiatorServiceCredential.SetCertificate 方法

定義

設定要用來加密服務傳送給用戶端之訊息的憑證。 只有以 MutualCertificateDuplex 訊息安全性驗證模式設定的繫結才會使用這個設定。

多載

SetCertificate(String, StoreLocation, StoreName)

可讓您藉由指定主體辨別名稱來指定要用來加密用戶端之訊息的憑證。 只有以 MutualCertificateDuplex 訊息安全性驗證模式設定的繫結才會使用這個設定。

SetCertificate(StoreLocation, StoreName, X509FindType, Object)

指定要用來加密用戶端之訊息的憑證。 只有以 MutualCertificateDuplex 訊息安全性驗證模式設定的繫結才會使用這個設定。

SetCertificate(String, StoreLocation, StoreName)

可讓您藉由指定主體辨別名稱來指定要用來加密用戶端之訊息的憑證。 只有以 MutualCertificateDuplex 訊息安全性驗證模式設定的繫結才會使用這個設定。

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)

參數

subjectName
String

主體辨別名稱。

storeLocation
StoreLocation

服務會用來取得憑證之憑證存放區的位置。

storeName
StoreName

要開啟的 X.509 憑證存放區名稱。

範例

下列程式碼將示範如何使用這個方法來設定憑證。

備註

如需有關 subjectName 參數的詳細資訊,請參閱SubjectName

storeLocation 的值包含在 StoreLocation 列舉型別中:

  • LocalMachine:指派給本機電腦的憑證存放區 (預設值)。

  • CurrentUser:目前使用者所使用的憑證存放區。

如果用戶端應用程式是在系統帳戶下執行,則憑證通常位於 LocalMachine。 如果用戶端應用程式是在使用者帳戶下執行,則憑證通常位於 CurrentUser

storeName 的值包含在 StoreName 列舉型別中。

適用於

SetCertificate(StoreLocation, StoreName, X509FindType, Object)

指定要用來加密用戶端之訊息的憑證。 只有以 MutualCertificateDuplex 訊息安全性驗證模式設定的繫結才會使用這個設定。

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)

參數

storeLocation
StoreLocation

服務會用來取得憑證之憑證存放區的位置。

storeName
StoreName

要開啟的 X.509 憑證存放區名稱。

findType
X509FindType

要執行之 X.509 搜尋的類型。

findValue
Object

要在 X.509 憑證存放區內搜尋的值。

範例

下列程式碼將示範如何使用這個方法來設定憑證。

備註

storeLocation 的值包含在 StoreLocation 列舉型別中:

  • LocalMachine:指派給本機電腦的憑證存放區 (預設值)。

  • CurrentUser:目前使用者所使用的憑證存放區。

如果應用程式是在系統帳戶下執行,則憑證通常位於 LocalMachine。 如果應用程式是在使用者帳戶下執行,則憑證通常位於 CurrentUser

storeName 的值包含在 StoreName 列舉型別中。

findType 的值包含在 X509FindType 列舉型別中。

最常用的列舉型別 (Enumeration) 是 FindBySubjectName,它會針對指定之存放區內憑證的主體名稱進行不區分大小寫的搜尋。 這可以是不精確的搜尋。 如果找不到憑證,或找到多個符合準則的憑證,將會擲回 InvalidOperationException

適用於