Freigeben über


X509Certificate-Klasse

Stellt Methoden bereit, die Sie beim Verwenden von X.509-Zertifikaten (v.3) unterstützen.

Namespace: System.Security.Cryptography.X509Certificates
Assembly: mscorlib (in mscorlib.dll)

Syntax

'Declaration
<SerializableAttribute> _
<ComVisibleAttribute(True)> _
Public Class X509Certificate
    Implements IDeserializationCallback, ISerializable
'Usage
Dim instance As X509Certificate
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public class X509Certificate : IDeserializationCallback, ISerializable
[SerializableAttribute] 
[ComVisibleAttribute(true)] 
public ref class X509Certificate : IDeserializationCallback, ISerializable
/** @attribute SerializableAttribute() */ 
/** @attribute ComVisibleAttribute(true) */ 
public class X509Certificate implements IDeserializationCallback, ISerializable
SerializableAttribute 
ComVisibleAttribute(true) 
public class X509Certificate implements IDeserializationCallback, ISerializable

Hinweise

ASN.1 DER ist das einzige Zertifizierungsformat, das von dieser Klasse unterstützt wird.

In den meisten Szenarios muss stattdessen die X509Certificate2-Klasse verwendet werden.

Beispiel

Im folgenden Beispiel wird ein X.509-Zertifikat aus einer Datei geladen, die ToString-Methode wird aufgerufen, und die Ergebnisse werden in der Konsole angezeigt.

Imports System
Imports System.Security.Cryptography.X509Certificates

Module X509

    Sub Main()

        ' The path to the certificate.
        Dim Certificate As String = "Certificate.cer"

        ' Load the certificate into an X509Certificate object.
        Dim cert As New X509Certificate(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 Module
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 = new X509Certificate(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);

    }

}
using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   
   // The path to the certificate.
   String^ Certificate = L"Certificate.cer";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = gcnew X509Certificate( 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 );
}

Vererbungshierarchie

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

Threadsicherheit

Alle öffentlichen statischen (Shared in Visual Basic) Member dieses Typs sind threadsicher. Bei Instanzmembern ist die Threadsicherheit nicht gewährleistet.

Plattformen

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile für Pocket PC, Windows Mobile für Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework unterstützt nicht alle Versionen sämtlicher Plattformen. Eine Liste der unterstützten Versionen finden Sie unter Systemanforderungen.

Versionsinformationen

.NET Framework

Unterstützt in: 2.0, 1.1, 1.0

.NET Compact Framework

Unterstützt in: 2.0, 1.0

Siehe auch

Referenz

X509Certificate-Member
System.Security.Cryptography.X509Certificates-Namespace