LocalCertificateSelectionCallback 대리자
정의
중요
일부 정보는 릴리스되기 전에 상당 부분 수정될 수 있는 시험판 제품과 관련이 있습니다. Microsoft는 여기에 제공된 정보에 대해 어떠한 명시적이거나 묵시적인 보증도 하지 않습니다.
인증에 사용되는 로컬 SSL(Secure Sockets Layer) 인증서를 선택합니다.
public delegate System::Security::Cryptography::X509Certificates::X509Certificate ^ LocalCertificateSelectionCallback(System::Object ^ sender, System::String ^ targetHost, X509CertificateCollection ^ localCertificates, X509Certificate ^ remoteCertificate, cli::array <System::String ^> ^ acceptableIssuers);
public delegate System.Security.Cryptography.X509Certificates.X509Certificate? LocalCertificateSelectionCallback(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate? remoteCertificate, string[] acceptableIssuers);
public delegate System.Security.Cryptography.X509Certificates.X509Certificate LocalCertificateSelectionCallback(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate? remoteCertificate, string[] acceptableIssuers);
public delegate System.Security.Cryptography.X509Certificates.X509Certificate LocalCertificateSelectionCallback(object sender, string targetHost, X509CertificateCollection localCertificates, X509Certificate remoteCertificate, string[] acceptableIssuers);
type LocalCertificateSelectionCallback = delegate of obj * string * X509CertificateCollection * X509Certificate * string[] -> X509Certificate
Public Delegate Function LocalCertificateSelectionCallback(sender As Object, targetHost As String, localCertificates As X509CertificateCollection, remoteCertificate As X509Certificate, acceptableIssuers As String()) As X509Certificate
매개 변수
- sender
- Object
이 유효성 검사에 대한 상태 정보가 들어 있는 개체입니다.
- targetHost
- String
클라이언트에서 지정한 호스트 서버입니다.
- localCertificates
- X509CertificateCollection
로컬 인증서가 들어 있는 X509CertificateCollection입니다.
- remoteCertificate
- X509Certificate
원격측을 인증하는 데 사용되는 인증서입니다.
반환 값
SSL 연결을 설정하는 데 사용되는 X509Certificate입니다.
예제
다음 코드 예제에서는 이 대리자의 메서드 구현을 보여 줍니다.
public static X509Certificate SelectLocalCertificate(
object sender,
string targetHost,
X509CertificateCollection localCertificates,
X509Certificate remoteCertificate,
string[] acceptableIssuers)
{
Console.WriteLine("Client is selecting a local certificate.");
if (acceptableIssuers != null &&
acceptableIssuers.Length > 0 &&
localCertificates != null &&
localCertificates.Count > 0)
{
// Use the first certificate that is from an acceptable issuer.
foreach (X509Certificate certificate in localCertificates)
{
string issuer = certificate.Issuer;
if (Array.IndexOf(acceptableIssuers, issuer) != -1)
return certificate;
}
}
if (localCertificates != null &&
localCertificates.Count > 0)
return localCertificates[0];
return null;
}
다음 코드 예제에서는 이 대리자의 instance 만드는 방법을 보여 줍니다.
// Server name must match the host name and the name on the host's certificate.
serverName = args[0];
// Create a TCP/IP client socket.
TcpClient client = new TcpClient(serverName,5000);
Console.WriteLine("Client connected.");
// Create an SSL stream that will close the client's stream.
SslStream sslStream = new SslStream(
client.GetStream(),
false,
new RemoteCertificateValidationCallback (ValidateServerCertificate),
new LocalCertificateSelectionCallback(SelectLocalCertificate)
);
설명
이 대리자는 클래스의 SslStream 인스턴스를 생성하는 데 사용됩니다. 클래스는 SslStream 클라이언트와 서버 간에 교환되는 정보를 보호하는 데 사용됩니다. 클라이언트와 서버는 이 대리자를 사용하여 인증에 사용할 인증서를 선택합니다.
확장 메서드
GetMethodInfo(Delegate) |
지정된 대리자가 나타내는 메서드를 나타내는 개체를 가져옵니다. |