X509Certificate.Import Methode

Definition

Füllt ein X509Certificate-Objekt auf.

Überlädt

Import(Byte[])
Veraltet.

Füllt das X509Certificate-Objekt mit Daten aus einem Bytearray auf.

Import(String)
Veraltet.

Füllt das X509Certificate-Objekt mit Informationen aus einer Zertifikatsdatei auf.

Import(Byte[], SecureString, X509KeyStorageFlags)
Veraltet.

Füllt ein X509Certificate-Objekt mithilfe der Daten aus einem Bytearray, eines Kennworts und eines Schlüsselspeicherflags auf.

Import(Byte[], String, X509KeyStorageFlags)
Veraltet.

Füllt das X509Certificate-Objekt mithilfe der Daten aus einem Bytearray, einem Kennwort und Flags auf, mit denen bestimmt wird, wie der private Schlüssel importiert wird.

Import(String, SecureString, X509KeyStorageFlags)
Veraltet.

Füllt ein X509Certificate-Objekt mit Informationen aus einer Zertifikatsdatei, einem Kennwort und einem Schlüsselspeicherflag auf.

Import(String, String, X509KeyStorageFlags)
Veraltet.

Füllt das X509Certificate-Objekt mit Informationen aus einer Zertifikatsdatei, einem Kennwort und einem X509KeyStorageFlags-Wert auf.

Import(Byte[])

Achtung

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

Füllt das X509Certificate-Objekt mit Daten aus einem Bytearray auf.

public:
 virtual void Import(cli::array <System::Byte> ^ rawData);
public virtual void Import (byte[] rawData);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (byte[] rawData);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (byte[] rawData);
abstract member Import : byte[] -> unit
override this.Import : byte[] -> unit
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : byte[] -> unit
override this.Import : byte[] -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Import : byte[] -> unit
override this.Import : byte[] -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
abstract member Import : byte[] -> unit
override this.Import : byte[] -> unit
Public Overridable Sub Import (rawData As Byte())

Parameter

rawData
Byte[]

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

Attribute

Ausnahmen

Der rawData-Parameter ist null.

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

Nur .NET Core und .NET 5 und höher: In allen Fällen.

Hinweise

Diese Methode kann verwendet werden, um das unformatierte Bytearray eines X.509-Zertifikats zu verwenden und das X509Certificate Objekt mit den zugeordneten Werten aufzufüllen.

Gilt für

Import(String)

Achtung

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

Füllt das X509Certificate-Objekt mit Informationen aus einer Zertifikatsdatei auf.

public:
 virtual void Import(System::String ^ fileName);
public virtual void Import (string fileName);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (string fileName);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (string fileName);
abstract member Import : string -> unit
override this.Import : string -> unit
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : string -> unit
override this.Import : string -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Import : string -> unit
override this.Import : string -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
abstract member Import : string -> unit
override this.Import : string -> unit
Public Overridable Sub Import (fileName As String)

Parameter

fileName
String

Der Name einer Zertifikatsdatei in Zeichenfolgendarstellung.

Attribute

Ausnahmen

Der fileName-Parameter ist null.

Nur .NET Core und .NET 5 und höher: In allen Fällen.

Beispiele

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

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;
   cert->Import(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 System;
using System.Security.Cryptography.X509Certificates;

class X509
{

    static void Main()
    {

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

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

        cert.Import(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);
    }
}
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

        cert.Import(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

Hinweise

Diese Methode verwendet eine Zertifikatdatei (z. B. eine Datei mit einer CER-Erweiterung), die ein X.509-Zertifikat darstellt, und füllt das X509Certificate Objekt mit dem Zertifikat auf, das die Datei enthält.

Gilt für

Import(Byte[], SecureString, X509KeyStorageFlags)

Achtung

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

Wichtig

Diese API ist nicht CLS-kompatibel.

Füllt ein X509Certificate-Objekt mithilfe der Daten aus einem Bytearray, eines Kennworts und eines Schlüsselspeicherflags auf.

public:
 virtual void Import(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public virtual void Import (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public virtual void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public virtual void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Security.SecurityCritical]
public virtual void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
abstract member Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.CLSCompliant(false)>]
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
abstract member Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Security.SecurityCritical>]
abstract member Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Overridable Sub Import (rawData As Byte(), password As SecureString, keyStorageFlags As X509KeyStorageFlags)

Parameter

rawData
Byte[]

Ein Bytearray, das Daten aus einem X.509-Zertifikat enthält.

password
SecureString

Das für den Zugriff auf die X.509-Zertifikatsdaten erforderliche Kennwort.

keyStorageFlags
X509KeyStorageFlags

Eine bitweise Kombination der Enumerationswerte, die steuern wo und wie das Zertifikat importiert wird.

Attribute

Ausnahmen

Der rawData-Parameter ist null.

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

Nur .NET Core und .NET 5 und höher: In allen Fällen.

Hinweise

Wichtig

Ein Kennwort wird niemals in Ihrem Quellcode hart codieren. Hartcodierte Kennwörter können mithilfe der Ildasm.exe (IL Disassembler), eines Hex-Editors oder einfach die Assembly in einem Text-Editor wie Notepad.exe geöffnet werden.

Gilt für

Import(Byte[], String, X509KeyStorageFlags)

Achtung

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

Füllt das X509Certificate-Objekt mithilfe der Daten aus einem Bytearray, einem Kennwort und Flags auf, mit denen bestimmt wird, wie der private Schlüssel importiert wird.

public:
 virtual void Import(cli::array <System::Byte> ^ rawData, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public virtual void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public virtual void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
abstract member Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
abstract member Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Overridable Sub Import (rawData As Byte(), password As String, keyStorageFlags As X509KeyStorageFlags)

Parameter

rawData
Byte[]

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

password
String

Das für den Zugriff auf die X.509-Zertifikatsdaten erforderliche Kennwort.

keyStorageFlags
X509KeyStorageFlags

Eine bitweise Kombination der Enumerationswerte, die steuern wo und wie das Zertifikat importiert wird.

Attribute

Ausnahmen

Der rawData-Parameter ist null.

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

Nur .NET Core und .NET 5 und höher: In allen Fällen.

Hinweise

Diese Methode kann verwendet werden, um ein Objekt mithilfe eines X509Certificate Kennworts für das durch das Bytearray dargestellte Zertifikat aufzufüllen. Der X509KeyStorageFlags Wert kann verwendet werden, um zu steuern, wo und wie der private Schlüssel importiert wird.

Gilt für

Import(String, SecureString, X509KeyStorageFlags)

Achtung

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

Wichtig

Diese API ist nicht CLS-kompatibel.

Füllt ein X509Certificate-Objekt mit Informationen aus einer Zertifikatsdatei, einem Kennwort und einem Schlüsselspeicherflag auf.

public:
 virtual void Import(System::String ^ fileName, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public virtual void Import (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public virtual void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public virtual void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Security.SecurityCritical]
public virtual void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
abstract member Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.CLSCompliant(false)>]
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
abstract member Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Security.SecurityCritical>]
abstract member Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Overridable Sub Import (fileName As String, password As SecureString, keyStorageFlags As X509KeyStorageFlags)

Parameter

fileName
String

Der Name einer Zertifikatsdatei.

password
SecureString

Das für den Zugriff auf die X.509-Zertifikatsdaten erforderliche Kennwort.

keyStorageFlags
X509KeyStorageFlags

Eine bitweise Kombination der Enumerationswerte, die steuern wo und wie das Zertifikat importiert wird.

Attribute

Ausnahmen

Der fileName-Parameter ist null.

Nur .NET Core und .NET 5 und höher: In allen Fällen.

Hinweise

Wichtig

Ein Kennwort wird niemals in Ihrem Quellcode hart codieren. Hartcodierte Kennwörter können mithilfe der Ildasm.exe (IL Disassembler), eines Hex-Editors oder einfach die Assembly in einem Text-Editor wie Notepad.exe geöffnet werden.

Gilt für

Import(String, String, X509KeyStorageFlags)

Achtung

X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.

Füllt das X509Certificate-Objekt mit Informationen aus einer Zertifikatsdatei, einem Kennwort und einem X509KeyStorageFlags-Wert auf.

public:
 virtual void Import(System::String ^ fileName, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public virtual void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public virtual void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.InteropServices.ComVisible(false)]
public virtual void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.InteropServices.ComVisible(false)]
[System.Security.SecurityCritical]
public virtual void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
abstract member Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
abstract member Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Security.SecurityCritical>]
abstract member Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
override this.Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Overridable Sub Import (fileName As String, password As String, keyStorageFlags As X509KeyStorageFlags)

Parameter

fileName
String

Der Name einer Zertifikatsdatei in Zeichenfolgendarstellung.

password
String

Das für den Zugriff auf die X.509-Zertifikatsdaten erforderliche Kennwort.

keyStorageFlags
X509KeyStorageFlags

Eine bitweise Kombination der Enumerationswerte, die steuern wo und wie das Zertifikat importiert wird.

Attribute

Ausnahmen

Der fileName-Parameter ist null.

Nur .NET Core und .NET 5 und höher: In allen Fällen.

Hinweise

Wichtig

Kein Kennwort innerhalb des Quellcodes hartcodieren. Hartcodierte Kennwörter können mithilfe der Ildasm.exe (IL Disassembler), eines Hex-Editors oder einfach die Assembly in einem Text-Editor wie Notepad.exe geöffnet werden.

Gilt für