다음을 통해 공유


X509CertificateRecipientClientCredential.SetDefaultCertificate 메서드

정의

서비스에 대해 사용할 기본 인증서를 지정합니다.

오버로드

SetDefaultCertificate(String, StoreLocation, StoreName)

서비스에 대해 사용할 기본 인증서를 지정합니다. 인증서 기반 메시지 보안을 사용하는 바인딩의 경우 서비스에 보내는 메시지를 암호화하는 데 이 인증서를 사용하며, 서비스에서는 클라이언트로 보내는 회신에 서명하는 데 이 인증서를 사용해야 합니다.

SetDefaultCertificate(StoreLocation, StoreName, X509FindType, Object)

서비스에 대해 사용할 기본 인증서를 지정합니다. 인증서 기반 메시지 보안을 사용하는 바인딩의 경우 서비스에 보내는 메시지를 암호화하는 데 이 인증서를 사용하며, 서비스에서는 클라이언트로 보내는 회신에 서명하는 데 이 인증서를 사용해야 합니다.

설명

이러한 메서드는 지정된 매개 변수와 일치하는 지정된 위치의 저장소에서 인증서를 가져옵니다.

인증서 기반 메시지 보안을 사용하는 바인딩의 경우 서비스에 보내는 메시지를 암호화하는 데 이 인증서를 사용하며, 서비스에서는 클라이언트로 보내는 회신에 서명하는 데 이 인증서를 사용해야 합니다.

SetDefaultCertificate(String, StoreLocation, StoreName)

서비스에 대해 사용할 기본 인증서를 지정합니다. 인증서 기반 메시지 보안을 사용하는 바인딩의 경우 서비스에 보내는 메시지를 암호화하는 데 이 인증서를 사용하며, 서비스에서는 클라이언트로 보내는 회신에 서명하는 데 이 인증서를 사용해야 합니다.

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

매개 변수

subjectName
String

제목의 고유 이름입니다.

storeLocation
StoreLocation

서비스 인증서를 가져오기 위해 서비스에서 사용하는 인증서 저장소의 위치입니다.

storeName
StoreName

열려는 X.509 인증서 저장소 이름입니다.

예외

subjectName이(가) null인 경우

읽기 전용인 자격 증명을 설정하려고 한 경우

예제

다음 코드에서는 이 메서드를 사용하여 사용할 X.509 인증서를 지정합니다.

public void snippet23(CalculatorClient cc)
{
    X509CertificateRecipientClientCredential rcc = cc.ClientCredentials.ServiceCertificate;
    rcc.SetDefaultCertificate("http://fabrikam.com/sts",
                             StoreLocation.CurrentUser,
                             StoreName.TrustedPeople);
}

설명

이 메서드는 매개 변수와 일치하는 지정된 위치의 저장소에서 인증서를 subjectName 가져옵니다.

storeLocation 값은 StoreLocation 열거형에 포함되어 있습니다.

  • LocalMachine: 로컬 컴퓨터에 할당된 인증서 저장소입니다.

  • CurrentUser: 현재 사용자가 사용하는 인증서 저장소(기본값)입니다.

시스템 계정으로 애플리케이션을 실행하는 경우 인증서는 대개 LocalMachine에 있습니다. 사용자 계정으로 애플리케이션을 실행하는 경우 인증서는 대개 CurrentUser에 있습니다.

storeName 값은 StoreName 열거형에 포함되어 있습니다.

적용 대상

SetDefaultCertificate(StoreLocation, StoreName, X509FindType, Object)

서비스에 대해 사용할 기본 인증서를 지정합니다. 인증서 기반 메시지 보안을 사용하는 바인딩의 경우 서비스에 보내는 메시지를 암호화하는 데 이 인증서를 사용하며, 서비스에서는 클라이언트로 보내는 회신에 서명하는 데 이 인증서를 사용해야 합니다.

public:
 void SetDefaultCertificate(System::Security::Cryptography::X509Certificates::StoreLocation storeLocation, System::Security::Cryptography::X509Certificates::StoreName storeName, System::Security::Cryptography::X509Certificates::X509FindType findType, System::Object ^ findValue);
public void SetDefaultCertificate (System.Security.Cryptography.X509Certificates.StoreLocation storeLocation, System.Security.Cryptography.X509Certificates.StoreName storeName, System.Security.Cryptography.X509Certificates.X509FindType findType, object findValue);
member this.SetDefaultCertificate : System.Security.Cryptography.X509Certificates.StoreLocation * System.Security.Cryptography.X509Certificates.StoreName * System.Security.Cryptography.X509Certificates.X509FindType * obj -> unit
Public Sub SetDefaultCertificate (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 인증서 저장소에서 검색할 값입니다.

예외

findValue이(가) null인 경우

읽기 전용인 자격 증명을 설정하려고 한 경우

예제

다음 코드에서는 이 메서드를 사용하여 사용할 X.509 인증서를 지정합니다.

public void snippet22(CalculatorClient cc)
{
    X509CertificateRecipientClientCredential rcc = cc.ClientCredentials.ServiceCertificate;
    rcc.SetDefaultCertificate(StoreLocation.CurrentUser,
                             StoreName.TrustedPeople,
                             X509FindType.FindBySubjectName,
                             "FabrikamSTS");
}

설명

이 메서드는 지정된 위치 및 매개 변수와 findValue 일치하는 저장소에서 인증서를 findType 가져옵니다.

storeLocation 값은 StoreLocation 열거형에 포함되어 있습니다.

  • LocalMachine: 로컬 컴퓨터에 할당된 인증서 저장소입니다.

  • CurrentUser: 현재 사용자가 사용하는 인증서 저장소(기본값)입니다.

시스템 계정으로 애플리케이션을 실행하는 경우 인증서는 대개 LocalMachine에 있습니다. 사용자 계정으로 애플리케이션을 실행하는 경우 인증서는 대개 CurrentUser에 있습니다.

storeName 값은 StoreName 열거형에 포함되어 있습니다.

findType 값은 X509FindType 열거형에 포함되어 있습니다.

가장 일반적으로 사용되는 열거형은 지정된 저장소에서 인증서 주체 이름에 대해 대/소문자를 구분하지 않는 검색을 수행하는 FindBySubjectName입니다. 검색이 정확하지 않을 수 있습니다. 조건과 일치하는 인증서가 없거나 여러 개인 경우 InvalidOperationException이 throw됩니다.

적용 대상