X509Certificate.Import Método

Definição

Preenche um X509Certificate objeto.

Sobrecargas

Name Description
Import(Byte[])
Obsoleto.
Obsoleto.

Preenche o X509Certificate objeto com dados de um array de bytes.

Import(String)
Obsoleto.
Obsoleto.

Preenche o X509Certificate objeto com informação de um ficheiro de certificado.

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

Preenche um X509Certificate objeto usando dados de um array de bytes, uma palavra-passe e uma flag de armazenamento de chaves.

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

Preenche o X509Certificate objeto usando dados de um array de bytes, uma palavra-passe e flags para determinar como a chave privada é importada.

Import(String, SecureString, X509KeyStorageFlags)
Obsoleto.
Obsoleto.

Preenche um X509Certificate objeto com informações de um ficheiro de certificado, uma palavra-passe e um flag de armazenamento de chaves.

Import(String, String, X509KeyStorageFlags)
Obsoleto.
Obsoleto.

Preenche o X509Certificate objeto com informações de um ficheiro de certificado, uma palavra-passe e um X509KeyStorageFlags valor.

Import(Byte[])

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Atenção

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

Atenção

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

Preenche o X509Certificate objeto com dados de um array de bytes.

public:
 virtual void Import(cli::array <System::Byte> ^ rawData);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import(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);
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : byte[] -> unit
override this.Import : byte[] -> unit
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())

Parâmetros

rawData
Byte[]

Um array de bytes contendo dados de um certificado X.509.

Atributos

Exceções

O rawData parâmetro é null.

-ou-

O comprimento do rawData parâmetro é 0.

.NET Core e .NET 5+ apenas: Em todos os casos.

Observações

Este método pode ser usado para pegar no array de bytes brutos de um certificado X.509 e preencher o X509Certificate objeto com os seus valores associados.

Aplica-se a

Import(String)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Atenção

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

Atenção

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

Preenche o X509Certificate objeto com informação de um ficheiro de certificado.

public:
 virtual void Import(System::String ^ fileName);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public virtual void Import(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);
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
abstract member Import : string -> unit
override this.Import : string -> unit
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)

Parâmetros

fileName
String

O nome de um ficheiro de certificado representado como uma cadeia.

Atributos

Exceções

O fileName parâmetro é null.

.NET Core e .NET 5+ apenas: Em todos os casos.

Exemplos

O exemplo seguinte carrega um certificado X.509 a partir de um ficheiro, chama o ToString método e apresenta os resultados na consola.

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

Observações

Este método utiliza um ficheiro de certificado (como um ficheiro com extensão .cer) que representa um certificado X.509, e preenche o X509Certificate objeto com o certificado que o ficheiro contém.

Aplica-se a

Import(Byte[], SecureString, X509KeyStorageFlags)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Atenção

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

Atenção

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

Importante

Esta API não está em conformidade com CLS.

Preenche um X509Certificate objeto usando dados de um array de bytes, uma palavra-passe e uma flag de armazenamento de chaves.

public:
 virtual void Import(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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);
[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)>]
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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
[<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)

Parâmetros

rawData
Byte[]

Um array de bytes que contém dados de um certificado X.509.

password
SecureString

A palavra-passe necessária para aceder aos dados do certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Uma combinação bit a bit dos valores de enumeração que controlam onde e como importar o certificado.

Atributos

Exceções

O rawData parâmetro é null.

-ou-

O comprimento do rawData parâmetro é 0.

.NET Core e .NET 5+ apenas: Em todos os casos.

Observações

Importante

Nunca codifiquem uma palavra-passe no seu código-fonte. As palavras-passe codificadas fixamente podem ser recuperadas de um assembly usando o Ildasm.exe (IL Disassembler), um editor hexadecimal ou simplesmente abrindo o assembly num editor de texto como o Notepad.exe.

Aplica-se a

Import(Byte[], String, X509KeyStorageFlags)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Atenção

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

Atenção

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

Preenche o X509Certificate objeto usando dados de um array de bytes, uma palavra-passe e flags para determinar como a chave privada é importada.

public:
 virtual void Import(cli::array <System::Byte> ^ rawData, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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.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);
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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
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)

Parâmetros

rawData
Byte[]

Um array de bytes contendo dados de um certificado X.509.

password
String

A palavra-passe necessária para aceder aos dados do certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Uma combinação bit a bit dos valores de enumeração que controlam onde e como importar o certificado.

Atributos

Exceções

O rawData parâmetro é null.

-ou-

O comprimento do rawData parâmetro é 0.

.NET Core e .NET 5+ apenas: Em todos os casos.

Observações

Este método pode ser usado para preencher um X509Certificate objeto usando uma palavra-passe para o certificado representado pelo array de bytes. O X509KeyStorageFlags valor pode ser usado para controlar onde e como a chave privada é importada.

Aplica-se a

Import(String, SecureString, X509KeyStorageFlags)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Atenção

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

Atenção

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

Importante

Esta API não está em conformidade com CLS.

Preenche um X509Certificate objeto com informações de um ficheiro de certificado, uma palavra-passe e um flag de armazenamento de chaves.

public:
 virtual void Import(System::String ^ fileName, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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);
[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)>]
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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
[<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)

Parâmetros

fileName
String

O nome de um ficheiro de certificado.

password
SecureString

A palavra-passe necessária para aceder aos dados do certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Uma combinação bit a bit dos valores de enumeração que controlam onde e como importar o certificado.

Atributos

Exceções

O fileName parâmetro é null.

.NET Core e .NET 5+ apenas: Em todos os casos.

Observações

Importante

Nunca codifiquem uma palavra-passe no seu código-fonte. As palavras-passe codificadas fixamente podem ser recuperadas de um assembly usando o Ildasm.exe (IL Disassembler), um editor hexadecimal ou simplesmente abrindo o assembly num editor de texto como o Notepad.exe.

Aplica-se a

Import(String, String, X509KeyStorageFlags)

Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs
Origem:
X509Certificate.cs

Atenção

X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.

Atenção

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

Preenche o X509Certificate objeto com informações de um ficheiro de certificado, uma palavra-passe e um X509KeyStorageFlags valor.

public:
 virtual void Import(System::String ^ fileName, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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.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);
[<System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader 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
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)

Parâmetros

fileName
String

O nome de um ficheiro de certificado representado como uma cadeia.

password
String

A palavra-passe necessária para aceder aos dados do certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Uma combinação bit a bit dos valores de enumeração que controlam onde e como importar o certificado.

Atributos

Exceções

O fileName parâmetro é null.

.NET Core e .NET 5+ apenas: Em todos os casos.

Observações

Importante

Nunca codifique uma palavra-passe no seu código-fonte. As palavras-passe codificadas fixamente podem ser recuperadas de um assembly usando o Ildasm.exe (IL Disassembler), um editor hexadecimal ou simplesmente abrindo o assembly num editor de texto como o Notepad.exe.

Aplica-se a