语言

X509Certificate.Import 方法

定义

填充对象 X509Certificate 。

重载

名称 说明
Import(Byte[])
已过时.
已过时.

X509Certificate使用字节数组中的数据填充对象。

Import(String)
已过时.
已过时.

X509Certificate使用证书文件中的信息填充对象。

Import(Byte[], SecureString, X509KeyStorageFlags)
已过时.
已过时.

X509Certificate使用字节数组、密码和密钥存储标志中的数据填充对象。

Import(Byte[], String, X509KeyStorageFlags)
已过时.
已过时.

X509Certificate使用字节数组中的数据、密码和标志填充对象,以确定私钥的导入方式。

Import(String, SecureString, X509KeyStorageFlags)
已过时.
已过时.

X509Certificate使用证书文件、密码和密钥存储标志中的信息填充对象。

Import(String, String, X509KeyStorageFlags)
已过时.
已过时.

X509Certificate使用证书文件、密码和X509KeyStorageFlags值中的信息填充对象。

Import(Byte[])

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

注意

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

注意

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

X509Certificate使用字节数组中的数据填充对象。

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())

参数

rawData
Byte[]

包含 X.509 证书中的数据的字节数组。

特性

例外

参数 rawData 为 null.

-或-

参数的 rawData 长度为 0。

仅限 .NET Core 和 .NET 5+ :在所有情况下。

注解

此方法可用于获取 X.509 证书的原始字节数组,并使用其关联的值填充 X509Certificate 对象。

适用于

Import(String)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

注意

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

注意

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

X509Certificate使用证书文件中的信息填充对象。

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)

参数

fileName
String

表示为字符串的证书文件的名称。

特性

例外

参数 fileName 为 null.

仅限 .NET Core 和 .NET 5+ :在所有情况下。

示例

以下示例从文件加载 X.509 证书,调用 ToString 该方法,并向控制台显示结果。

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

注解

此方法使用表示 X.509 证书的证书文件(如具有.cer扩展名的文件),并使用该文件包含的证书填充 X509Certificate 对象。

适用于

Import(Byte[], SecureString, X509KeyStorageFlags)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

注意

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

注意

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

重要

此 API 不符合 CLS。

X509Certificate使用字节数组、密码和密钥存储标志中的数据填充对象。

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)

参数

rawData
Byte[]

包含 X.509 证书中的数据的字节数组。

password
SecureString

访问 X.509 证书数据所需的密码。

keyStorageFlags
X509KeyStorageFlags

用于控制证书导入位置以及如何导入证书的枚举值的按位组合。

特性

例外

参数 rawData 为 null.

-或-

参数的 rawData 长度为 0。

仅限 .NET Core 和 .NET 5+ :在所有情况下。

注解

Important

从不对源代码中的密码进行硬编码。 可以使用 Ildasm.exe(IL 反汇编程序)、十六进制编辑器或直接在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码的密码。

适用于

Import(Byte[], String, X509KeyStorageFlags)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

注意

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

注意

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

X509Certificate使用字节数组中的数据、密码和标志填充对象,以确定私钥的导入方式。

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)

参数

rawData
Byte[]

包含 X.509 证书中的数据的字节数组。

password
String

访问 X.509 证书数据所需的密码。

keyStorageFlags
X509KeyStorageFlags

用于控制证书导入位置以及如何导入证书的枚举值的按位组合。

特性

例外

参数 rawData 为 null.

-或-

参数的 rawData 长度为 0。

仅限 .NET Core 和 .NET 5+ :在所有情况下。

注解

此方法可用于使用字节数组表示的证书的密码填充 X509Certificate 对象。 X509KeyStorageFlags该值可用于控制私钥的导入位置和方式。

适用于

Import(String, SecureString, X509KeyStorageFlags)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

注意

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

注意

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

重要

此 API 不符合 CLS。

X509Certificate使用证书文件、密码和密钥存储标志中的信息填充对象。

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)

参数

fileName
String

证书文件的名称。

password
SecureString

访问 X.509 证书数据所需的密码。

keyStorageFlags
X509KeyStorageFlags

用于控制证书导入位置以及如何导入证书的枚举值的按位组合。

特性

例外

参数 fileName 为 null.

仅限 .NET Core 和 .NET 5+ :在所有情况下。

注解

Important

从不对源代码中的密码进行硬编码。 可以使用 Ildasm.exe(IL 反汇编程序)、十六进制编辑器或直接在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码的密码。

适用于

Import(String, String, X509KeyStorageFlags)

Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs
Source:
X509Certificate.cs

注意

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

注意

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

X509Certificate使用证书文件、密码和X509KeyStorageFlags值中的信息填充对象。

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)

参数

fileName
String

表示为字符串的证书文件的名称。

password
String

访问 X.509 证书数据所需的密码。

keyStorageFlags
X509KeyStorageFlags

用于控制证书导入位置以及如何导入证书的枚举值的按位组合。

特性

例外

参数 fileName 为 null.

仅限 .NET Core 和 .NET 5+ :在所有情况下。

注解

Important

从不对源代码中的密码进行硬编码。 可以使用 Ildasm.exe(IL 反汇编程序)、十六进制编辑器或直接在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码的密码。

适用于