SslStream.LocalCertificate Property
.NET Framework 2.0
Note: This property is new in the .NET Framework version 2.0.
Gets the certificate used to authenticate the local endpoint.
Namespace: System.Net.Security
Assembly: System (in system.dll)
Assembly: System (in system.dll)
/** @property */ public X509Certificate get_LocalCertificate ()
public function get LocalCertificate () : X509Certificate
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.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}.", localCertificate.Subject, localCertificate.GetEffectiveDateString(), localCertificate.GetExpirationDateString()); } 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}.", remoteCertificate.Subject, remoteCertificate.GetEffectiveDateString(), remoteCertificate.GetExpirationDateString()); } else { Console.WriteLine("Remote certificate is null."); } }
Windows 98, Windows 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 .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.