언어

SmtpClient.ClientCertificates 속성

정의

SSL(Secure Sockets Layer) 연결을 설정하는 데 사용할 인증서를 지정합니다.

public:
 property System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ ClientCertificates { System::Security::Cryptography::X509Certificates::X509CertificateCollection ^ get(); };
public System.Security.Cryptography.X509Certificates.X509CertificateCollection ClientCertificates { get; }
member this.ClientCertificates : System.Security.Cryptography.X509Certificates.X509CertificateCollection
Public ReadOnly Property ClientCertificates As X509CertificateCollection

속성 값

X509CertificateCollection하나 이상의 클라이언트 인증서를 보유하는 경우 기본값은 구성 파일의 메일 구성 특성에서 파생됩니다.

예제

다음 코드 예제에서는 SMTP 서버와 SSL 연결을 설정하고 연결을 사용하여 이메일을 보냅니다.

public static void CreateTestMessage(string server)
{
    string to = "jane@contoso.com";
    string from = "ben@contoso.com";
    MailMessage message = new MailMessage(from, to);
    message.Subject = "Using the new SMTP client.";
    message.Body = @"Using this new feature, you can send an email message from an application very easily.";
    SmtpClient client = new SmtpClient(server);
    // Credentials are necessary if the server requires the client
    // to authenticate before it will send email on the client's behalf.
    client.UseDefaultCredentials = true;
                client.EnableSsl = true;
    client.Send(message);
}

설명

클라이언트 인증서는 기본적으로 선택 사항입니다. 그러나 서버 구성을 사용하려면 클라이언트가 초기 연결 협상의 일부로 유효한 인증서를 제시해야 할 수 있습니다.

이 컬렉션을 수정해도 기존 캐시된 SMTP 연결이 무효화되거나 새 TLS 핸드셰이크가 트리거되지 않습니다. 연결을 다시 사용하는 경우 연결을 만들 때 설정된 보안 컨텍스트를 계속 사용합니다. 다른 보안 또는 ID 컨텍스트 SmtpClient 를 사용하려면 삭제하고 새 인스턴스를 만듭니다. 또는 새 연결 및 핸드셰이크를 강제로 적용하려면 캐시된 연결을 무효화하는 속성을 변경합니다.

메모

프레임워크는 SSL 세션이 만들어질 때 캐시하고 가능한 경우 새 요청에 캐시된 세션을 다시 사용하려고 시도합니다. SSL 세션을 다시 사용하려고 할 때 프레임워크는 첫 번째 요소 ClientCertificates (있는 경우)를 사용하거나 비어 있는 경우 ClientCertificates 익명 세션을 다시 사용하려고 합니다.

적용 대상

참고 항목