Freigeben über


X509Certificate-Konstruktor (Byte )

Initialisiert eine neue Instanz der X509Certificate-Klasse, die aus einer Folge von Bytes zum Darstellen eines X.509v3-Zertifikats definiert ist.

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

Syntax

'Declaration
Public Sub New ( _
    data As Byte() _
)
'Usage
Dim data As Byte()

Dim instance As New X509Certificate(data)
public X509Certificate (
    byte[] data
)
public:
X509Certificate (
    array<unsigned char>^ data
)
public X509Certificate (
    byte[] data
)
public function X509Certificate (
    data : byte[]
)

Parameter

  • data
    Ein Bytearray mit Daten aus einem X.509-Zertifikat.

Ausnahmen

Ausnahmetyp Bedingung

ArgumentException

Der rawData-Parameter ist NULL (Nothing in Visual Basic).

– oder –

Die Länge des rawData-Parameters ist 0 (null).

Hinweise

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

Beispiel

Im folgenden Beispiel wird eine X.509-Zertifikatsdatei in ein X509Certificate-Objekt geladen, und das Zertifikat wird als Bytearray exportiert. Anschließend wird das Bytearray in ein anderes X509Certificate-Objekt importiert.

Imports System
Imports System.Security.Cryptography.X509Certificates


Module X509

    Sub Main()

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

        ' Load the certificate into an X509Certificate object.
        Dim cert As New X509Certificate(Certificate)


        Dim certData As Byte() = cert.Export(X509ContentType.Cert)

        Dim newCert As New X509Certificate(certData)

        ' Get the value.
        Dim resultsTrue As String = newCert.ToString(True)

        ' Display the value to the console.
        Console.WriteLine(resultsTrue)

        ' Get the value.
        Dim resultsFalse As String = newCert.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 = "test.pfx";

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


        byte[] certData = cert.Export(X509ContentType.Cert);

        X509Certificate newCert = new X509Certificate(certData);

        // Get the value.
        string resultsTrue = newCert.ToString(true);

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

        // Get the value.
        string resultsFalse = newCert.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"test.pfx";
   
   // Load the certificate into an X509Certificate object.
   X509Certificate^ cert = gcnew X509Certificate( Certificate );
   array<Byte>^certData = cert->Export( X509ContentType::Cert );
   X509Certificate^ newCert = gcnew X509Certificate( certData );
   
   // Get the value.
   String^ resultsTrue = newCert->ToString( true );
   
   // Display the value to the console.
   Console::WriteLine( resultsTrue );
   
   // Get the value.
   String^ resultsFalse = newCert->ToString( false );
   
   // Display the value to the console.
   Console::WriteLine( resultsFalse );
}

.NET Framework-Sicherheit

  • KeyContainerPermission  für die Berechtigung zum Erstellen eines Schlüsselcontainers. Zugeordnete Enumeration: Create Sicherheitsaktion: Demand

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-Klasse
X509Certificate-Member
System.Security.Cryptography.X509Certificates-Namespace