SslStream.RemoteCertificate Property

Gets the certificate used to authenticate the remote endpoint.

Namespace: System.Net.Security
Assembly: System (in system.dll)

public virtual X509Certificate RemoteCertificate { get; }
/** @property */
public X509Certificate get_RemoteCertificate ()

public function get RemoteCertificate () : X509Certificate

Not applicable.

Property Value

An X509Certificate object that represents the certificate supplied for authentication or a null reference (Nothing in Visual Basic) if no certificate was supplied.

Exception typeCondition


Authentication failed or has not occurred.

The following code example demonstrates displaying the certificate returned by this property.

static void DisplayCertificateInformation(SslStream stream)
    Console.WriteLine("Certificate revocation list checked: {0}", stream.CheckCertRevocationStatus);
    X509Certificate localCertificate = stream.LocalCertificate;
    if (stream.LocalCertificate != null)
        Console.WriteLine("Local cert was issued to {0} and is valid from {1} until {2}.",
     } else
        Console.WriteLine("Local certificate is null.");
    // Display the properties of the client's certificate.
    X509Certificate remoteCertificate = stream.RemoteCertificate;
    if (stream.RemoteCertificate != null)
    Console.WriteLine("Remote cert was issued to {0} and is valid from {1} until {2}.",
    } else
        Console.WriteLine("Remote certificate is null.");

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

Community Additions