X509Certificate2Collection.Import Method

Definition

Imports a certificate into a X509Certificate2Collection object.

Overloads

Import(String, String, X509KeyStorageFlags)

Imports a certificate file that requires a password into a X509Certificate2Collection object.

Import(String, ReadOnlySpan<Char>, X509KeyStorageFlags)

Imports the certificates from the specified file a into this collection.

Import(ReadOnlySpan<Byte>, String, X509KeyStorageFlags)

Imports the certificates from the provided data into this collection.

Import(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, X509KeyStorageFlags)

Imports the certificates from the provided data into this collection.

Import(ReadOnlySpan<Byte>)

Imports the certificates from the provided data into this collection.

Import(String)

Imports a certificate file into a X509Certificate2Collection object.

Import(Byte[])

Imports a certificate in the form of a byte array into a X509Certificate2Collection object.

Import(Byte[], String, X509KeyStorageFlags)

Imports a certificate, in the form of a byte array that requires a password to access the certificate, into a X509Certificate2Collection object.

Import(String, String, X509KeyStorageFlags)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports a certificate file that requires a password into a X509Certificate2Collection object.

public:
 void Import(System::String ^ fileName, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
public void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
member this.Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Sub Import (fileName As String, password As String, Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)
Public Sub Import (fileName As String, password As String, keyStorageFlags As X509KeyStorageFlags)

Parameters

fileName
String

The name of the file containing the certificate information.

password
String

The password required to access the certificate information.

keyStorageFlags
X509KeyStorageFlags

A bitwise combination of the enumeration values that control how and where the certificate is imported.

Remarks

This method can be used with a PFX/PKCS12 file or other certificate files that require a password. Key containers associated with certificates in the PFX/PKCS12 file can be created and X509KeyStorageFlags value can be used to control this process. Note that if you do not create a key container, the private key is not persisted.

Note that a PFX/PKCS12 file can contain more than one certificate. This method imports the first certificate associated with the private key or, if no private key is found, the first certificate found.

This method supports the following X509ContentType types:

Applies to

Import(String, ReadOnlySpan<Char>, X509KeyStorageFlags)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports the certificates from the specified file a into this collection.

public void Import (string fileName, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
member this.Import : string * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Sub Import (fileName As String, password As ReadOnlySpan(Of Char), Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)

Parameters

fileName
String

The name of the file containing the certificate information.

password
ReadOnlySpan<Char>

The password required to access the certificate data.

keyStorageFlags
X509KeyStorageFlags

A bitwise combination of the enumeration values that control where and how to import the certificate.

Applies to

Import(ReadOnlySpan<Byte>, String, X509KeyStorageFlags)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports the certificates from the provided data into this collection.

public void Import (ReadOnlySpan<byte> rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
member this.Import : ReadOnlySpan<byte> * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Sub Import (rawData As ReadOnlySpan(Of Byte), password As String, Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)

Parameters

rawData
ReadOnlySpan<Byte>

The certificate data to read.

password
String

The password required to access the certificate data.

keyStorageFlags
X509KeyStorageFlags

A bitwise combination of the enumeration values that control where and how to import the certificate.

Applies to

Import(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, X509KeyStorageFlags)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports the certificates from the provided data into this collection.

public void Import (ReadOnlySpan<byte> rawData, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
member this.Import : ReadOnlySpan<byte> * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Sub Import (rawData As ReadOnlySpan(Of Byte), password As ReadOnlySpan(Of Char), Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)

Parameters

rawData
ReadOnlySpan<Byte>

The certificate data to read.

password
ReadOnlySpan<Char>

The password required to access the certificate data.

keyStorageFlags
X509KeyStorageFlags

A bitwise combination of the enumeration values that control where and how to import the certificate.

Applies to

Import(ReadOnlySpan<Byte>)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports the certificates from the provided data into this collection.

public:
 void Import(ReadOnlySpan<System::Byte> rawData);
public void Import (ReadOnlySpan<byte> rawData);
member this.Import : ReadOnlySpan<byte> -> unit
Public Sub Import (rawData As ReadOnlySpan(Of Byte))

Parameters

rawData
ReadOnlySpan<Byte>

The certificate data to read.

Applies to

Import(String)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports a certificate file into a X509Certificate2Collection object.

public:
 void Import(System::String ^ fileName);
public void Import (string fileName);
member this.Import : string -> unit
Public Sub Import (fileName As String)

Parameters

fileName
String

The name of the file containing the certificate information.

Remarks

This method supports the following X509ContentType types:

Applies to

Import(Byte[])

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports a certificate in the form of a byte array into a X509Certificate2Collection object.

public:
 void Import(cli::array <System::Byte> ^ rawData);
public void Import (byte[] rawData);
member this.Import : byte[] -> unit
Public Sub Import (rawData As Byte())

Parameters

rawData
Byte[]

A byte array containing data from an X.509 certificate.

Remarks

This method imports a certificate in the form of a byte array into a X509Certificate2Collection object. This method supports the following X509ContentType types:

Applies to

Import(Byte[], String, X509KeyStorageFlags)

Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs
Source:
X509Certificate2Collection.cs

Imports a certificate, in the form of a byte array that requires a password to access the certificate, into a X509Certificate2Collection object.

public:
 void Import(cli::array <System::Byte> ^ rawData, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
public void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
member this.Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Sub Import (rawData As Byte(), password As String, Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)
Public Sub Import (rawData As Byte(), password As String, keyStorageFlags As X509KeyStorageFlags)

Parameters

rawData
Byte[]

A byte array containing data from an X509Certificate2 object.

password
String

The password required to access the certificate information.

keyStorageFlags
X509KeyStorageFlags

A bitwise combination of the enumeration values that control how and where the certificate is imported.

Remarks

This method can be used with a PFX/PKCS12 binary large object (BLOB) protected by a password. Key containers associated with certificates in the PFX/PKCS12 BLOB can be created and the X509KeyStorageFlags value can be used to control this process. Note that if you do not create a key container, the private key is not persisted.

This method imports a certificate byte array into a collection of certificates. This method supports the following X509ContentType types:

Applies to