X509Certificate 构造函数
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
初始化 X509Certificate 类的新实例。
重载
X509Certificate()
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
X509Certificate and X509Certificate2 are immutable. Use the appropriate constructor to create a new certificate.
注意
X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.
初始化 X509Certificate 类的新实例。
public:
X509Certificate();
public X509Certificate ();
[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 X509Certificate ();
[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}")]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate ();
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("X509Certificate and X509Certificate2 are immutable. Use X509CertificateLoader to create a new certificate.", DiagnosticId="SYSLIB0026", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate ();
Public Sub New ()
- 属性
注解
ASN.1 DER 是此类支持的唯一证书格式。
适用于
X509Certificate(Byte[])
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
初始化从表示 X.509v3 证书的字节序列定义的 X509Certificate 类的新实例。
public:
X509Certificate(cli::array <System::Byte> ^ data);
public X509Certificate (byte[] data);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (byte[] data);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (byte[] data);
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (data As Byte())
参数
- data
- Byte[]
一个包含 X.509 证书数据的字节数组。
- 属性
例外
示例
以下示例将 X.509 证书文件加载到对象 X509Certificate 中,将证书导出为字节数组,然后将字节数组导入另一个 X509Certificate 对象。
using namespace System;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
// The path to the certificate.
String^ Certificate = L"test.pfx";
// Load the certificate into an X509Certificate object.
X509Certificate^ cert = gcnew X509Certificate( Certificate );
array<Byte>^certData = cert->Export( X509ContentType::Cert );
X509Certificate^ newCert = gcnew X509Certificate( certData );
// Get the value.
String^ resultsTrue = newCert->ToString( true );
// Display the value to the console.
Console::WriteLine( resultsTrue );
// Get the value.
String^ resultsFalse = newCert->ToString( false );
// Display the value to the console.
Console::WriteLine( resultsFalse );
}
using System;
using System.Security.Cryptography.X509Certificates;
public class X509
{
public static void Main()
{
// The path to the certificate.
string Certificate = "test.pfx";
// Load the certificate into an X509Certificate object.
X509Certificate cert = new X509Certificate(Certificate);
byte[] certData = cert.Export(X509ContentType.Cert);
X509Certificate newCert = new X509Certificate(certData);
// Get the value.
string resultsTrue = newCert.ToString(true);
// Display the value to the console.
Console.WriteLine(resultsTrue);
// Get the value.
string resultsFalse = newCert.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 = "test.pfx"
' Load the certificate into an X509Certificate object.
Dim cert As New X509Certificate(Certificate)
Dim certData As Byte() = cert.Export(X509ContentType.Cert)
Dim newCert As New X509Certificate(certData)
' Get the value.
Dim resultsTrue As String = newCert.ToString(True)
' Display the value to the console.
Console.WriteLine(resultsTrue)
' Get the value.
Dim resultsFalse As String = newCert.ToString(False)
' Display the value to the console.
Console.WriteLine(resultsFalse)
End Sub
End Module
注解
ASN.1 DER 是此类支持的唯一证书格式。
如果通过为 data
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(IntPtr)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
使用非托管 PCCERT_CONTEXT
结构的句柄初始化 X509Certificate 类的一个新实例。
public:
X509Certificate(IntPtr handle);
public X509Certificate (IntPtr handle);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (IntPtr handle);
[System.Security.SecurityCritical]
public X509Certificate (IntPtr handle);
new System.Security.Cryptography.X509Certificates.X509Certificate : nativeint -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : nativeint -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Security.SecurityCritical>]
new System.Security.Cryptography.X509Certificates.X509Certificate : nativeint -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (handle As IntPtr)
参数
- handle
-
IntPtr
nativeint
非托管 PCCERT_CONTEXT
结构的一个句柄。
- 属性
例外
句柄参数未表示有效的 PCCERT_CONTEXT
结构。
注解
此构造函数使用 Microsoft 加密 API 证书上下文PCCERT_CONTEXT
的句柄创建新X509Certificate对象。
重要
此构造函数创建证书上下文的副本。 不要假定传递给构造函数的上下文结构有效;它可能已被释放。 可以从 属性获取当前 PCCERT_CONTEXT
结构 Handle 的副本,但它仅在对象的生存期内 X509Certificate 有效。
适用于
X509Certificate(X509Certificate)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
使用另一个 X509Certificate 类初始化 X509Certificate 类的一个新实例。
public:
X509Certificate(System::Security::Cryptography::X509Certificates::X509Certificate ^ cert);
public X509Certificate (System.Security.Cryptography.X509Certificates.X509Certificate cert);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (System.Security.Cryptography.X509Certificates.X509Certificate cert);
new System.Security.Cryptography.X509Certificates.X509Certificate : System.Security.Cryptography.X509Certificates.X509Certificate -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : System.Security.Cryptography.X509Certificates.X509Certificate -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (cert As X509Certificate)
参数
- cert
- X509Certificate
从中初始化此类的 X509Certificate 类。
- 属性
例外
cert
参数的值为 null
。
注解
ASN.1 DER 是此类支持的唯一证书格式。
适用于
X509Certificate(String)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
使用 PKCS7 签名文件的名称初始化 X509Certificate 类的新实例。
public:
X509Certificate(System::String ^ fileName);
public X509Certificate (string fileName);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (string fileName);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (string fileName);
new System.Security.Cryptography.X509Certificates.X509Certificate : string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (fileName As String)
参数
- fileName
- String
PKCS7 签名文件的名称。
- 属性
例外
fileName
参数为 null
。
示例
以下示例从文件加载 X.509 证书,调用 ToString 方法,并将结果显示到控制台。
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( 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;
public class X509
{
public static void Main()
{
// The path to the certificate.
string Certificate = "Certificate.cer";
// Load the certificate into an X509Certificate object.
X509Certificate cert = new X509Certificate(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(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
注解
ASN.1 DER 是此类支持的唯一证书格式。
如果通过为 fileName
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(Byte[], SecureString)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
重要
此 API 不符合 CLS。
使用一个字节数组和一个密码初始化 X509Certificate 类的新实例。
public:
X509Certificate(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password);
[System.CLSCompliant(false)]
public X509Certificate (byte[] rawData, System.Security.SecureString? password);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (byte[] rawData, System.Security.SecureString? password);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (byte[] rawData, System.Security.SecureString? password);
[System.CLSCompliant(false)]
public X509Certificate (byte[] rawData, System.Security.SecureString password);
public X509Certificate (byte[] rawData, System.Security.SecureString password);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (rawData As Byte(), password As SecureString)
参数
- rawData
- Byte[]
包含 X.509 证书数据的字节数组。
- password
- SecureString
访问 X.509 证书数据所需的密码。
- 属性
例外
注解
ASN.1 DER 是此类支持的唯一证书格式。
重要
切勿在源代码中对密码进行硬编码。 可以使用 Ildasm.exe (IL 反汇编程序) (十六进制编辑器)或通过在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码密码。
如果通过为 rawData
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(Byte[], String)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
使用一个字节数组和一个密码初始化 X509Certificate 类的新实例。
public:
X509Certificate(cli::array <System::Byte> ^ rawData, System::String ^ password);
public X509Certificate (byte[] rawData, string? password);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (byte[] rawData, string? password);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (byte[] rawData, string? password);
public X509Certificate (byte[] rawData, string password);
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * string -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (rawData As Byte(), password As String)
参数
- rawData
- Byte[]
一个包含 X.509 证书数据的字节数组。
- password
- String
访问 X.509 证书数据所需的密码。
- 属性
例外
注解
ASN.1 DER 是此类支持的唯一证书格式。
重要
切勿在源代码中对密码进行硬编码。 可以使用 Ildasm.exe (IL 反汇编程序) (十六进制编辑器)或通过在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码密码。
如果通过为 rawData
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(SerializationInfo, StreamingContext)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
This API supports obsolete formatter-based serialization. It should not be called or extended by application code.
使用一个 X509Certificate 对象和一个 SerializationInfo 结构初始化 StreamingContext 类的一个新实例。
public:
X509Certificate(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
public X509Certificate (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
[System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.Cryptography.X509Certificates.X509Certificate : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Obsolete("This API supports obsolete formatter-based serialization. It should not be called or extended by application code.", DiagnosticId="SYSLIB0051", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (info As SerializationInfo, context As StreamingContext)
参数
- info
- SerializationInfo
一个描述序列化信息的 SerializationInfo 对象。
- context
- StreamingContext
一个描述如何执行序列化的 StreamingContext 结构。
- 属性
例外
适用于
X509Certificate(String, SecureString)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
重要
此 API 不符合 CLS。
使用一个证书文件名和一个密码初始化 X509Certificate 类的新实例。
public:
X509Certificate(System::String ^ fileName, System::Security::SecureString ^ password);
[System.CLSCompliant(false)]
public X509Certificate (string fileName, System.Security.SecureString? password);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (string fileName, System.Security.SecureString? password);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (string fileName, System.Security.SecureString? password);
[System.CLSCompliant(false)]
public X509Certificate (string fileName, System.Security.SecureString password);
public X509Certificate (string fileName, System.Security.SecureString password);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (fileName As String, password As SecureString)
参数
- fileName
- String
一个证书文件的名称。
- password
- SecureString
访问 X.509 证书数据所需的密码。
- 属性
例外
fileName
参数为 null
。
注解
ASN.1 DER 是此类支持的唯一证书格式。 使用正确的密码调用此构造函数会解密私钥并将其保存到密钥容器。
重要
切勿在源代码中对密码进行硬编码。 可以使用 Ildasm.exe (IL 反汇编程序) (十六进制编辑器)或通过在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码密码。
如果通过为 fileName
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(String, String)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
使用 PKCS7 签名文件的名称和一个用于访问该证书的密码初始化 X509Certificate 类的新实例。
public:
X509Certificate(System::String ^ fileName, System::String ^ password);
public X509Certificate (string fileName, string? password);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (string fileName, string? password);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (string fileName, string? password);
public X509Certificate (string fileName, string password);
new System.Security.Cryptography.X509Certificates.X509Certificate : string * string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * string -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * string -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (fileName As String, password As String)
参数
- fileName
- String
PKCS7 签名文件的名称。
- password
- String
访问 X.509 证书数据所需的密码。
- 属性
例外
fileName
参数为 null
。
注解
ASN.1 DER 是此类支持的唯一证书格式。 使用正确的密码调用此构造函数会解密私钥并将其保存到密钥容器。
如果通过为 fileName
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(Byte[], SecureString, X509KeyStorageFlags)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
重要
此 API 不符合 CLS。
使用一个字节数组、一个密码和一个密钥存储标志初始化 X509Certificate 类的新实例。
public:
X509Certificate(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (rawData As Byte(), password As SecureString, keyStorageFlags As X509KeyStorageFlags)
参数
- rawData
- Byte[]
包含 X.509 证书数据的字节数组。
- password
- SecureString
访问 X.509 证书数据所需的密码。
- keyStorageFlags
- X509KeyStorageFlags
一个枚举值的按位组合,这些值控制在何处以及如何导入证书。
- 属性
例外
注解
使用正确的密码调用此构造函数会解密私钥,并将其保存到 Microsoft 加密 API 加密服务提供程序 (CSP) 。
ASN.1 DER 是此类支持的唯一证书格式。
重要
切勿在源代码中对密码进行硬编码。 可以使用 Ildasm.exe (IL 反汇编程序) (十六进制编辑器)或通过在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码密码。
如果通过为 rawData
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(Byte[], String, X509KeyStorageFlags)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
使用一个字节数组、一个密码和一个密钥存储标志初始化 X509Certificate 类的新实例。
public:
X509Certificate(cli::array <System::Byte> ^ rawData, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public X509Certificate (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (rawData As Byte(), password As String, keyStorageFlags As X509KeyStorageFlags)
参数
- rawData
- Byte[]
一个包含 X.509 证书数据的字节数组。
- password
- String
访问 X.509 证书数据所需的密码。
- keyStorageFlags
- X509KeyStorageFlags
一个枚举值的按位组合,这些值控制在何处以及如何导入证书。
- 属性
例外
注解
此构造函数使用字节数组、访问证书数据所需的密码和密钥存储标志创建新 X509Certificate 对象。 使用正确的密码调用此构造函数会解密私钥,并将其保存到 Microsoft 加密 API 加密服务提供程序 (CSP) 。
值 X509KeyStorageFlags 可用于控制私钥的导入位置和方式。
ASN.1 DER 是此类支持的唯一证书格式。
重要
切勿在源代码中对密码进行硬编码。 可以使用 Ildasm.exe (IL 反汇编程序) (十六进制编辑器)或通过在文本编辑器(如 Notepad.exe)中打开程序集来检索硬编码密码。
如果通过为 rawData
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(String, SecureString, X509KeyStorageFlags)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
重要
此 API 不符合 CLS。
使用一个证书文件名、一个密码和一个密钥存储标志初始化 X509Certificate 类的新实例。
public:
X509Certificate(System::String ^ fileName, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
new System.Security.Cryptography.X509Certificates.X509Certificate : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (fileName As String, password As SecureString, keyStorageFlags As X509KeyStorageFlags)
参数
- fileName
- String
一个证书文件的名称。
- password
- SecureString
访问 X.509 证书数据所需的密码。
- keyStorageFlags
- X509KeyStorageFlags
一个枚举值的按位组合,这些值控制在何处以及如何导入证书。
- 属性
例外
fileName
参数为 null
。
注解
如果通过为 fileName
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。
适用于
X509Certificate(String, String, X509KeyStorageFlags)
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
- Source:
- X509Certificate.cs
注意
Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.
使用 PKCS7 签名文件的名称、一个用于访问该证书的密码和一个密钥存储标志初始化 X509Certificate 类的新实例。
public:
X509Certificate(System::String ^ fileName, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public X509Certificate (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
[System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")]
public X509Certificate (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
new System.Security.Cryptography.X509Certificates.X509Certificate : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
[<System.Obsolete("Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.", DiagnosticId="SYSLIB0057", UrlFormat="https://aka.ms/dotnet-warnings/{0}")>]
new System.Security.Cryptography.X509Certificates.X509Certificate : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate
Public Sub New (fileName As String, password As String, keyStorageFlags As X509KeyStorageFlags)
参数
- fileName
- String
PKCS7 签名文件的名称。
- password
- String
访问 X.509 证书数据所需的密码。
- keyStorageFlags
- X509KeyStorageFlags
一个枚举值的按位组合,这些值控制在何处以及如何导入证书。
- 属性
例外
fileName
参数为 null
。
注解
如果通过为 fileName
指定 PKCS7 签名文件存储来创建X509Certificate证书,X509Certificate则会为签名存储的证书而不是存储区中的任何证书创建 。