Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

X509Certificate Class

Defines the common language runtime implementation of an X.509 v.3 certificate.

For a list of all members of this type, see X509Certificate Members.

System.Object
   System.Security.Cryptography.X509Certificates.X509Certificate

[Visual Basic]
<Serializable>
Public Class X509Certificate
[C#]
[Serializable]
public class X509Certificate
[C++]
[Serializable]
public __gc class X509Certificate
[JScript]
public
   Serializable
class X509Certificate

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Remarks

ASN.1 DER is the only certificate format supported by this class.

Example

[Visual Basic] 
Imports System
Imports System.Security.Cryptography.X509Certificates




Public Class X509
   
   
   Public Shared Sub Main()
      
      ' The path to the certificate.
      Dim Certificate As String = "Certificate.cer"
      
      ' Load the certificate into an X509Certificate object.
      Dim cert As X509Certificate = X509Certificate.CreateFromCertFile(Certificate)
      
      ' Get the value.
      Dim resultsTrue As String = cert.ToString(True)
      
      ' Display the value to the console.
      Console.WriteLine(resultsTrue)
      
      ' Get the value.
      Dim resultsFalse As String = cert.ToString(False)
      
      ' Display the value to the console.
      Console.WriteLine(resultsFalse)
   End Sub  
End Class 


[C#] 

using System;
using System.Security.Cryptography.X509Certificates;


public class X509
{

    public static void Main()
    {

        // The path to the certificate.
        string Certificate =  "Certificate.cer";

        // Load the certificate into an X509Certificate object.
        X509Certificate cert = X509Certificate.CreateFromCertFile(Certificate);

        // Get the value.
        string resultsTrue = cert.ToString(true);
       
        // Display the value to the console.
        Console.WriteLine(resultsTrue);

        // Get the value.
        string resultsFalse = cert.ToString(false);
       
        // Display the value to the console.
        Console.WriteLine(resultsFalse);
  
    }

}

[C++] 

#using <mscorlib.dll>
using namespace System;
using namespace System::Security::Cryptography::X509Certificates;

int main()
{

    // The path to the certificate.
    String* Certificate =  S"Certificate.cer";

    // Load the certificate into an X509Certificate object.
    X509Certificate* cert = X509Certificate::CreateFromCertFile(Certificate);

    // Get the value.
    String* resultsTrue = cert->ToString(true);

    // Display the value to the console.
    Console::WriteLine(resultsTrue);

    // Get the value.
    String* resultsFalse = cert->ToString(false);

    // Display the value to the console.
    Console::WriteLine(resultsFalse);

}

[JScript] No example is available for JScript. To view a Visual Basic, C#, or C++ example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Security.Cryptography.X509Certificates

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, .NET Compact Framework

Assembly: Mscorlib (in Mscorlib.dll)

See Also

X509Certificate Members | System.Security.Cryptography.X509Certificates Namespace

Show:
© 2014 Microsoft