Compartir vía


X509Certificate2.Import Método

Definición

Rellena un objeto X509Certificate2 con la información proporcionada del certificado.

Sobrecargas

Import(Byte[])
Obsoletos.

Rellena un objeto X509Certificate2 con datos de una matriz de bytes.

Import(String)
Obsoletos.

Rellena un objeto X509Certificate2 con información de un archivo de certificado.

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

Rellena un objeto X509Certificate2 utilizando los datos de una matriz de bytes, una contraseña y una marca de almacenamiento de claves.

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

Rellena un objeto X509Certificate2 utilizando los datos de una matriz de bytes, una contraseña y los marcadores para determinar cómo importar la clave privada.

Import(String, SecureString, X509KeyStorageFlags)
Obsoletos.

Rellena un objeto X509Certificate2 con información de un archivo de certificado, una contraseña y una marca de almacenamiento de claves.

Import(String, String, X509KeyStorageFlags)
Obsoletos.

Rellena un objeto X509Certificate2 con información de un archivo de certificado, una contraseña y un valor de X509KeyStorageFlags.

Import(Byte[])

Source:
X509Certificate2.cs
Source:
X509Certificate2.cs
Source:
X509Certificate2.cs

Precaución

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

Rellena un objeto X509Certificate2 con datos de una matriz de bytes.

public:
 override void Import(cli::array <System::Byte> ^ rawData);
public override 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 override void Import (byte[] rawData);
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}")>]
override this.Import : byte[] -> unit
Public Overrides Sub Import (rawData As Byte())

Parámetros

rawData
Byte[]

Matriz de bytes que contiene los datos de un certificado X.509.

Atributos

Comentarios

Este método se puede usar para tomar una matriz de bytes sin formato de un certificado X.509 y rellenar el X509Certificate2 objeto con sus valores asociados.

Dado que este método acepta solo una matriz de bytes, solo se puede usar para tipos de certificado que no requieren una contraseña, incluido un certificado X.509 codificado en Base64 o con codificación DER o un certificado PFX/PKCS12. Tenga en cuenta que un certificado PFX/PKCS12 puede contener más de un certificado. En ese caso, se usa el primer certificado asociado a una clave privada o, si no se encuentra ninguna clave privada, se usa el primer certificado.

Se aplica a

Import(String)

Source:
X509Certificate2.cs
Source:
X509Certificate2.cs
Source:
X509Certificate2.cs

Precaución

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

Rellena un objeto X509Certificate2 con información de un archivo de certificado.

public:
 override void Import(System::String ^ fileName);
public override 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 override void Import (string fileName);
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}")>]
override this.Import : string -> unit
Public Overrides Sub Import (fileName As String)

Parámetros

fileName
String

Nombre de un certificado.

Atributos

Comentarios

Este método usa un archivo de certificado, como un archivo con una extensión .cer, que representa un certificado X.509 y rellena el X509Certificate2 objeto con el certificado que contiene el archivo.

Este método se puede usar con varios tipos de certificado, incluidos certificados X.509 codificados en Base64 o codificados en DER, certificados PFX/PKCS12 y certificados de firmante como Authenticode. Tenga en cuenta que un certificado PFX/PKCS12 puede contener más de un certificado. En ese caso, se usa el primer certificado asociado a una clave privada o, si no se encuentra ninguna clave privada, se usa el primer certificado.

Se aplica a

Import(Byte[], SecureString, X509KeyStorageFlags)

Source:
X509Certificate2.cs
Source:
X509Certificate2.cs
Source:
X509Certificate2.cs

Precaución

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

Importante

Esta API no es conforme a CLS.

Rellena un objeto X509Certificate2 utilizando los datos de una matriz de bytes, una contraseña y una marca de almacenamiento de claves.

public:
 override void Import(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public override 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 override void Import (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public override void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public override void Import (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
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}")>]
override this.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 Overrides Sub Import (rawData As Byte(), password As SecureString, keyStorageFlags As X509KeyStorageFlags)

Parámetros

rawData
Byte[]

Matriz de bytes que contiene los datos de un certificado X.509.

password
SecureString

Contraseña requerida para obtener acceso a los datos del certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Combinación bit a bit de los valores de enumeración que controlan dónde y cómo importar el certificado.

Atributos

Comentarios

Puede usar este método para tipos de certificado, como certificados X.509 codificados en Base64 o con codificación DER, o certificados PFX/PKCS12. Tenga en cuenta que un certificado PFX/PKCS12 puede contener más de un certificado. En ese caso, se usa el primer certificado asociado a una clave privada o, si no se encuentra ninguna clave privada, se usa el primer certificado.

Importante

Nunca codifique de forma rígida una contraseña dentro del código fuente. Las contraseñas codificadas de forma rígida se pueden recuperar de un ensamblado mediante el Ildasm.exe (Desensamblador de IL), un editor hexadecimal o simplemente abriendo el ensamblado en un editor de texto, como Notepad.exe.

Se aplica a

Import(Byte[], String, X509KeyStorageFlags)

Source:
X509Certificate2.cs
Source:
X509Certificate2.cs
Source:
X509Certificate2.cs

Precaución

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

Rellena un objeto X509Certificate2 utilizando los datos de una matriz de bytes, una contraseña y los marcadores para determinar cómo importar la clave privada.

public:
 override void Import(cli::array <System::Byte> ^ rawData, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public override 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 override void Import (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public override void Import (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
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}")>]
override this.Import : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Overrides Sub Import (rawData As Byte(), password As String, keyStorageFlags As X509KeyStorageFlags)

Parámetros

rawData
Byte[]

Matriz de bytes que contiene los datos de un certificado X.509.

password
String

Contraseña requerida para obtener acceso a los datos del certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Combinación bit a bit de los valores de enumeración que controlan dónde y cómo importar el certificado.

Atributos

Ejemplos

En el ejemplo de código siguiente se crea un ejecutable de línea de comandos que toma un archivo de certificado como argumento e imprime varias propiedades de certificado en la consola.

#using <System.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Permissions;
using namespace System::IO;
using namespace System::Security::Cryptography::X509Certificates;

//Reads a file.
array<Byte>^ ReadFile( String^ fileName )
{
   FileStream^ f = gcnew FileStream( fileName,FileMode::Open,FileAccess::Read );
   int size = (int)f->Length;
   array<Byte>^data = gcnew array<Byte>(size);
   size = f->Read( data, 0, size );
   f->Close();
   return data;
}

[SecurityPermissionAttribute(SecurityAction::LinkDemand, Unrestricted = true)]
int main()
{
   array<String^>^args = Environment::GetCommandLineArgs();

   //Test for correct number of arguments.
   if ( args->Length < 2 )
   {
      Console::WriteLine( "Usage: CertInfo <filename>" );
      return  -1;
   }

   try
   {
      System::Security::Cryptography::X509Certificates::X509Certificate2 ^ x509 =
            gcnew System::Security::Cryptography::X509Certificates::X509Certificate2;

      //Create X509Certificate2 object from .cer file.
      array<Byte>^rawData = ReadFile( args[ 1 ] );

      x509->Import(rawData);

      //Print to console information contained in the certificate.
      Console::WriteLine( "{0}Subject: {1}{0}", Environment::NewLine, x509->Subject );
      Console::WriteLine( "{0}Issuer: {1}{0}", Environment::NewLine, x509->Issuer );
      Console::WriteLine( "{0}Version: {1}{0}", Environment::NewLine, x509->Version );
      Console::WriteLine( "{0}Valid Date: {1}{0}", Environment::NewLine, x509->NotBefore );
      Console::WriteLine( "{0}Expiry Date: {1}{0}", Environment::NewLine, x509->NotAfter );
      Console::WriteLine( "{0}Thumbprint: {1}{0}", Environment::NewLine, x509->Thumbprint );
      Console::WriteLine( "{0}Serial Number: {1}{0}", Environment::NewLine, x509->SerialNumber );
      Console::WriteLine( "{0}Friendly Name: {1}{0}", Environment::NewLine, x509->PublicKey->Oid->FriendlyName );
      Console::WriteLine( "{0}Public Key Format: {1}{0}", Environment::NewLine, x509->PublicKey->EncodedKeyValue->Format(true) );
      Console::WriteLine( "{0}Raw Data Length: {1}{0}", Environment::NewLine, x509->RawData->Length );
      Console::WriteLine( "{0}Certificate to string: {1}{0}", Environment::NewLine, x509->ToString( true ) );
      Console::WriteLine( "{0}Certificate to XML String: {1}{0}", Environment::NewLine, x509->PublicKey->Key->ToXmlString( false ) );

      //Add the certificate to a X509Store.
      X509Store ^ store = gcnew X509Store;
      store->Open( OpenFlags::MaxAllowed );
      store->Add( x509 );
      store->Close();
   }
   catch ( DirectoryNotFoundException^ )
   {
      Console::WriteLine( "Error: The directory specified could not be found." );
   }
   catch ( IOException^ )
   {
      Console::WriteLine( "Error: A file in the directory could not be accessed." );
   }
   catch ( NullReferenceException^ )
   {
      Console::WriteLine( "File must be a .cer file. Program does not have access to that type of file." );
   }

}
using System;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.IO;
using System.Security.Cryptography.X509Certificates;

class CertInfo
{
    //Reads a file.
    internal static byte[] ReadFile (string fileName)
    {
        FileStream f = new FileStream(fileName, FileMode.Open, FileAccess.Read);
        int size = (int)f.Length;
        byte[] data = new byte[size];
        size = f.Read(data, 0, size);
        f.Close();
        return data;
    }
    //Main method begins here.
    static void Main(string[] args)
    {
        //Test for correct number of arguments.
        if (args.Length < 1)
        {
            Console.WriteLine("Usage: CertInfo <filename>");
            return;
        }
        try
        {
            X509Certificate2 x509 = new X509Certificate2();
            //Create X509Certificate2 object from .cer file.
            byte[] rawData = ReadFile(args[0]);
            x509.Import(rawData);

            //Print to console information contained in the certificate.
            Console.WriteLine("{0}Subject: {1}{0}", Environment.NewLine, x509.Subject);
            Console.WriteLine("{0}Issuer: {1}{0}", Environment.NewLine, x509.Issuer);
            Console.WriteLine("{0}Version: {1}{0}", Environment.NewLine, x509.Version);
            Console.WriteLine("{0}Valid Date: {1}{0}", Environment.NewLine, x509.NotBefore);
            Console.WriteLine("{0}Expiry Date: {1}{0}", Environment.NewLine, x509.NotAfter);
            Console.WriteLine("{0}Thumbprint: {1}{0}", Environment.NewLine, x509.Thumbprint);
            Console.WriteLine("{0}Serial Number: {1}{0}", Environment.NewLine, x509.SerialNumber);
            Console.WriteLine("{0}Friendly Name: {1}{0}", Environment.NewLine, x509.PublicKey.Oid.FriendlyName);
            Console.WriteLine("{0}Public Key Format: {1}{0}", Environment.NewLine, x509.PublicKey.EncodedKeyValue.Format(true));
            Console.WriteLine("{0}Raw Data Length: {1}{0}", Environment.NewLine, x509.RawData.Length);
            Console.WriteLine("{0}Certificate to string: {1}{0}", Environment.NewLine, x509.ToString(true));
            Console.WriteLine("{0}Certificate to XML String: {1}{0}", Environment.NewLine, x509.PublicKey.Key.ToXmlString(false));

            //Add the certificate to a X509Store.
            X509Store store = new X509Store();
            store.Open(OpenFlags.MaxAllowed);
            store.Add(x509);
            store.Close();
        }
        catch (DirectoryNotFoundException)
        {
               Console.WriteLine("Error: The directory specified could not be found.");
        }
        catch (IOException)
        {
            Console.WriteLine("Error: A file in the directory could not be accessed.");
        }
        catch (NullReferenceException)
        {
            Console.WriteLine("File must be a .cer file. Program does not have access to that type of file.");
        }
    }
}
Imports System.Security.Cryptography
Imports System.Security.Permissions
Imports System.IO
Imports System.Security.Cryptography.X509Certificates

Class CertInfo

    'Reads a file.
    Friend Shared Function ReadFile(ByVal fileName As String) As Byte()
        Dim f As New FileStream(fileName, FileMode.Open, FileAccess.Read)
        Dim size As Integer = Fix(f.Length)
        Dim data(size - 1) As Byte
        size = f.Read(data, 0, size)
        f.Close()
        Return data

    End Function 

    <SecurityPermission(SecurityAction.LinkDemand, Unrestricted:=True)> _
    Shared Sub Main(ByVal args() As String)
        'Test for correct number of arguments.
        If args.Length < 1 Then
            Console.WriteLine("Usage: CertInfo <filename>")
            Return
        End If
        Try
            Dim x509 As New X509Certificate2()
            'Create X509Certificate2 object from .cer file.
            Dim rawData As Byte() = ReadFile(args(0))
            
            x509.Import(rawData)

            'Print to console information contained in the certificate.
            Console.WriteLine("{0}Subject: {1}{0}", Environment.NewLine, x509.Subject)
            Console.WriteLine("{0}Issuer: {1}{0}", Environment.NewLine, x509.Issuer)
            Console.WriteLine("{0}Version: {1}{0}", Environment.NewLine, x509.Version)
            Console.WriteLine("{0}Valid Date: {1}{0}", Environment.NewLine, x509.NotBefore)
            Console.WriteLine("{0}Expiry Date: {1}{0}", Environment.NewLine, x509.NotAfter)
            Console.WriteLine("{0}Thumbprint: {1}{0}", Environment.NewLine, x509.Thumbprint)
            Console.WriteLine("{0}Serial Number: {1}{0}", Environment.NewLine, x509.SerialNumber)
            Console.WriteLine("{0}Friendly Name: {1}{0}", Environment.NewLine, x509.PublicKey.Oid.FriendlyName)
            Console.WriteLine("{0}Public Key Format: {1}{0}", Environment.NewLine, x509.PublicKey.EncodedKeyValue.Format(True))
            Console.WriteLine("{0}Raw Data Length: {1}{0}", Environment.NewLine, x509.RawData.Length)
            Console.WriteLine("{0}Certificate to string: {1}{0}", Environment.NewLine, x509.ToString(True))

            Console.WriteLine("{0}Certificate to XML String: {1}{0}", Environment.NewLine, x509.PublicKey.Key.ToXmlString(False))

            'Add the certificate to a X509Store.
            Dim store As New X509Store()
            store.Open(OpenFlags.MaxAllowed)
            store.Add(x509)
            store.Close()

        Catch dnfExcept As DirectoryNotFoundException
            Console.WriteLine("Error: The directory specified could not be found.")
        Catch ioExpcept As IOException
            Console.WriteLine("Error: A file in the directory could not be accessed.")
        Catch nrExcept As NullReferenceException
            Console.WriteLine("File must be a .cer file. Program does not have access to that type of file.")
        End Try

    End Sub
End Class

Comentarios

Este método se puede usar para rellenar un X509Certificate2 objeto mediante una contraseña para el certificado representado por la matriz de bytes. El X509KeyStorageFlags valor se puede usar para controlar dónde y cómo importar la clave privada.

Este método acepta una matriz de bytes y se puede usar para tipos de certificado como certificados X.509 codificados en Base64 o X.509 codificados por DER o certificados PFX/PKCS12. Tenga en cuenta que un certificado PFX/PKCS12 puede contener más de un certificado. En ese caso, se usa el primer certificado asociado a una clave privada o, si no se encuentra ninguna clave privada, se usa el primer certificado.

Importante

Nunca codifique de forma rígida una contraseña dentro del código fuente. Las contraseñas codificadas de forma rígida se pueden recuperar de un ensamblado mediante el Ildasm.exe (Desensamblador de IL), un editor hexadecimal o simplemente abriendo el ensamblado en un editor de texto, como Notepad.exe.

Se aplica a

Import(String, SecureString, X509KeyStorageFlags)

Source:
X509Certificate2.cs
Source:
X509Certificate2.cs
Source:
X509Certificate2.cs

Precaución

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

Importante

Esta API no es conforme a CLS.

Rellena un objeto X509Certificate2 con información de un archivo de certificado, una contraseña y una marca de almacenamiento de claves.

public:
 override void Import(System::String ^ fileName, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public override 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 override void Import (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public override void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public override void Import (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
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}")>]
override this.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 Overrides Sub Import (fileName As String, password As SecureString, keyStorageFlags As X509KeyStorageFlags)

Parámetros

fileName
String

Nombre de un archivo de certificado.

password
SecureString

Contraseña requerida para obtener acceso a los datos del certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Combinación bit a bit de los valores de enumeración que controlan dónde y cómo importar el certificado.

Atributos

Comentarios

Nota de seguridad Nunca codifique de forma rígida una contraseña dentro del código fuente. Las contraseñas codificadas de forma rígida se pueden recuperar de un ensamblado mediante el Ildasm.exe (Desensamblador de IL), un editor hexadecimal o simplemente abriendo el ensamblado en un editor de texto, como Notepad.exe.

Se aplica a

Import(String, String, X509KeyStorageFlags)

Source:
X509Certificate2.cs
Source:
X509Certificate2.cs
Source:
X509Certificate2.cs

Precaución

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

Rellena un objeto X509Certificate2 con información de un archivo de certificado, una contraseña y un valor de X509KeyStorageFlags.

public:
 override void Import(System::String ^ fileName, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public override 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 override void Import (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public override void Import (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
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}")>]
override this.Import : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> unit
Public Overrides Sub Import (fileName As String, password As String, keyStorageFlags As X509KeyStorageFlags)

Parámetros

fileName
String

Nombre de un archivo de certificado.

password
String

Contraseña requerida para obtener acceso a los datos del certificado X.509.

keyStorageFlags
X509KeyStorageFlags

Combinación bit a bit de los valores de enumeración que controlan dónde y cómo importar el certificado.

Atributos

Comentarios

Este método se puede usar para rellenar un X509Certificate2 objeto con información de un archivo de certificado, una contraseña y un X509KeyStorageFlags valor.

Importante

Nunca codifique de forma rígida una contraseña dentro del código fuente. Las contraseñas codificadas de forma rígida se pueden recuperar de un ensamblado mediante el Ildasm.exe (Desensamblador de IL), un editor hexadecimal o simplemente abriendo el ensamblado en un editor de texto, como Notepad.exe.

Se aplica a