Bagikan melalui


X509Certificate2 Konstruktor

Definisi

Menginisialisasi instans baru kelas X509Certificate2.

Overload

X509Certificate2()
Kedaluwarsa.
Kedaluwarsa.

Menginisialisasi instans baru kelas X509Certificate2.

X509Certificate2(String, String, X509KeyStorageFlags)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat, kata sandi yang digunakan untuk mengakses sertifikat, dan bendera penyimpanan kunci.

X509Certificate2(String, SecureString, X509KeyStorageFlags)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat, kata sandi, dan bendera penyimpanan kunci.

X509Certificate2(String, ReadOnlySpan<Char>, X509KeyStorageFlags)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat, kata sandi, dan bendera penyimpanan kunci.

X509Certificate2(Byte[], String, X509KeyStorageFlags)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte, kata sandi, dan bendera penyimpanan kunci.

X509Certificate2(Byte[], SecureString, X509KeyStorageFlags)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte, kata sandi, dan bendera penyimpanan kunci.

X509Certificate2(String, String)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat dan kata sandi yang digunakan untuk mengakses sertifikat.

X509Certificate2(String, SecureString)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat dan kata sandi.

X509Certificate2(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, X509KeyStorageFlags)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas dari data sertifikat, kata sandi, dan bendera penyimpanan kunci.

X509Certificate2(Byte[], String)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte dan kata sandi.

X509Certificate2(Byte[], SecureString)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte dan kata sandi.

X509Certificate2(String)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat.

X509Certificate2(X509Certificate)

Menginisialisasi instans X509Certificate2 baru kelas menggunakan X509Certificate objek .

X509Certificate2(SerializationInfo, StreamingContext)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan serialisasi yang ditentukan dan mengalirkan informasi konteks.

X509Certificate2(ReadOnlySpan<Byte>)
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas dari data sertifikat.

X509Certificate2(IntPtr)

Menginisialisasi instans X509Certificate2 baru kelas menggunakan handel yang tidak dikelola.

X509Certificate2(Byte[])
Kedaluwarsa.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan informasi dari array byte.

X509Certificate2()

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

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

Perhatian

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

Menginisialisasi instans baru kelas X509Certificate2.

public:
 X509Certificate2();
public X509Certificate2 ();
[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 X509Certificate2 ();
[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 X509Certificate2 ();
[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 X509Certificate2 ();
Public Sub New ()
Atribut

Contoh

Contoh kode berikut membuka penyimpanan sertifikat pengguna saat ini, hanya memilih sertifikat aktif, lalu memungkinkan pengguna untuk memilih satu atau beberapa sertifikat. Contohnya kemudian menulis informasi sertifikat ke konsol.

#using <System.dll>
#using <System.Security.dll>

using namespace System;
using namespace System::Security::Cryptography;
using namespace System::Security::Permissions;
using namespace System::IO;
using namespace System::Security::Cryptography::X509Certificates;
int main()
{
   try
   {
      X509Store ^ store = gcnew X509Store( "MY",StoreLocation::CurrentUser );
      store->Open( static_cast<OpenFlags>(OpenFlags::ReadOnly | OpenFlags::OpenExistingOnly) );
      X509Certificate2Collection ^ collection = dynamic_cast<X509Certificate2Collection^>(store->Certificates);
      X509Certificate2Collection ^ fcollection = dynamic_cast<X509Certificate2Collection^>(collection->Find( X509FindType::FindByTimeValid, DateTime::Now, false ));
      X509Certificate2Collection ^ scollection = X509Certificate2UI::SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag::MultiSelection);
      Console::WriteLine( "Number of certificates: {0}{1}", scollection->Count, Environment::NewLine );
      System::Collections::IEnumerator^ myEnum = scollection->GetEnumerator();
      while ( myEnum->MoveNext() )
      {
         X509Certificate2 ^ x509 = safe_cast<X509Certificate2 ^>(myEnum->Current);
         array<Byte>^rawdata = x509->RawData;
         Console::WriteLine( "Content Type: {0}{1}", X509Certificate2::GetCertContentType( rawdata ), Environment::NewLine );
         Console::WriteLine( "Friendly Name: {0}{1}", x509->FriendlyName, Environment::NewLine );
         Console::WriteLine( "Certificate Verified?: {0}{1}", x509->Verify(), Environment::NewLine );
         Console::WriteLine( "Simple Name: {0}{1}", x509->GetNameInfo( X509NameType::SimpleName, true ), Environment::NewLine );
         Console::WriteLine( "Signature Algorithm: {0}{1}", x509->SignatureAlgorithm->FriendlyName, Environment::NewLine );
         Console::WriteLine( "Private Key: {0}{1}", x509->PrivateKey->ToXmlString( false ), Environment::NewLine );
         Console::WriteLine( "Public Key: {0}{1}", x509->PublicKey->Key->ToXmlString( false ), Environment::NewLine );
         Console::WriteLine( "Certificate Archived?: {0}{1}", x509->Archived, Environment::NewLine );
         Console::WriteLine( "Length of Raw Data: {0}{1}", x509->RawData->Length, Environment::NewLine );
         x509->Reset();
      }
      store->Close();
   }
   catch ( CryptographicException^ ) 
   {
      Console::WriteLine( "Information could not be written out for this certificate." );
   }

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

class CertSelect
{
    static void Main()
    {
        X509Store store = new X509Store("MY",StoreLocation.CurrentUser);
        store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly);

        X509Certificate2Collection collection = (X509Certificate2Collection)store.Certificates;
        X509Certificate2Collection fcollection = (X509Certificate2Collection)collection.Find(X509FindType.FindByTimeValid,DateTime.Now,false);
        X509Certificate2Collection scollection = X509Certificate2UI.SelectFromCollection(fcollection, "Test Certificate Select","Select a certificate from the following list to get information on that certificate",X509SelectionFlag.MultiSelection);
        Console.WriteLine("Number of certificates: {0}{1}",scollection.Count,Environment.NewLine);

        foreach (X509Certificate2 x509 in scollection)
        {
            try
            {
                byte[] rawdata = x509.RawData;
                Console.WriteLine("Content Type: {0}{1}",X509Certificate2.GetCertContentType(rawdata),Environment.NewLine);
                Console.WriteLine("Friendly Name: {0}{1}",x509.FriendlyName,Environment.NewLine);
                Console.WriteLine("Certificate Verified?: {0}{1}",x509.Verify(),Environment.NewLine);
                Console.WriteLine("Simple Name: {0}{1}",x509.GetNameInfo(X509NameType.SimpleName,true),Environment.NewLine);
                Console.WriteLine("Signature Algorithm: {0}{1}",x509.SignatureAlgorithm.FriendlyName,Environment.NewLine);
                Console.WriteLine("Public Key: {0}{1}",x509.PublicKey.Key.ToXmlString(false),Environment.NewLine);
                Console.WriteLine("Certificate Archived?: {0}{1}",x509.Archived,Environment.NewLine);
                Console.WriteLine("Length of Raw Data: {0}{1}",x509.RawData.Length,Environment.NewLine);
                X509Certificate2UI.DisplayCertificate(x509);
                x509.Reset();
            }
            catch (CryptographicException)
            {
                Console.WriteLine("Information could not be written out for this certificate.");
            }
        }
        store.Close();
    }
}
Imports System.Security.Cryptography
Imports System.Security.Permissions
Imports System.IO
Imports System.Security.Cryptography.X509Certificates

Class CertSelect

    Shared Sub Main()

        Dim store As New X509Store("MY", StoreLocation.CurrentUser)
        store.Open(OpenFlags.ReadOnly Or OpenFlags.OpenExistingOnly)

        Dim collection As X509Certificate2Collection = CType(store.Certificates, X509Certificate2Collection)
        Dim fcollection As X509Certificate2Collection = CType(collection.Find(X509FindType.FindByTimeValid, DateTime.Now, False), X509Certificate2Collection)
        Dim scollection As X509Certificate2Collection = X509Certificate2UI.SelectFromCollection(fcollection, "Test Certificate Select", "Select a certificate from the following list to get information on that certificate", X509SelectionFlag.MultiSelection)
        Console.WriteLine("Number of certificates: {0}{1}", scollection.Count, Environment.NewLine)
         
        For Each x509 As X509Certificate2 In scollection
            Try
                Dim rawdata As Byte() = x509.RawData
                Console.WriteLine("Content Type: {0}{1}", X509Certificate2.GetCertContentType(rawdata), Environment.NewLine)
                Console.WriteLine("Friendly Name: {0}{1}", x509.FriendlyName, Environment.NewLine)
                Console.WriteLine("Certificate Verified?: {0}{1}", x509.Verify(), Environment.NewLine)
                Console.WriteLine("Simple Name: {0}{1}", x509.GetNameInfo(X509NameType.SimpleName, True), Environment.NewLine)
                Console.WriteLine("Signature Algorithm: {0}{1}", x509.SignatureAlgorithm.FriendlyName, Environment.NewLine)
                Console.WriteLine("Public Key: {0}{1}", x509.PublicKey.Key.ToXmlString(False), Environment.NewLine)
                Console.WriteLine("Certificate Archived?: {0}{1}", x509.Archived, Environment.NewLine)
                Console.WriteLine("Length of Raw Data: {0}{1}", x509.RawData.Length, Environment.NewLine)
                X509Certificate2UI.DisplayCertificate(x509)
                x509.Reset()         
             Catch cExcept As CryptographicException
                 Console.WriteLine("Information could not be written out for this certificate.")
             End Try
        Next x509

        store.Close()
    End Sub
End Class

Keterangan

Konstruktor ini membuat objek kosong X509Certificate2 , tidak seperti konstruktor lain untuk kelas ini yang menggunakan informasi sertifikat dari array byte, pointer, atau file sertifikat.

Berlaku untuk

X509Certificate2(String, String, X509KeyStorageFlags)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat, kata sandi yang digunakan untuk mengakses sertifikat, dan bendera penyimpanan kunci.

public:
 X509Certificate2(System::String ^ fileName, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public X509Certificate2 (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (string fileName, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate2 (string fileName, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : string * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (fileName As String, password As String, keyStorageFlags As X509KeyStorageFlags)

Parameter

fileName
String

Nama file sertifikat.

password
String

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

keyStorageFlags
X509KeyStorageFlags

Kombinasi bitwise dari nilai enumerasi yang mengontrol di mana dan bagaimana mengimpor sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan nama file sertifikat, kata sandi yang diperlukan untuk mengakses sertifikat, dan bendera penyimpanan kunci.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (IL Disassembler), editor hex, atau hanya dengan membuka perakitan di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk fileName, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat di dalam penyimpanan.

Berlaku untuk

X509Certificate2(String, SecureString, X509KeyStorageFlags)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Penting

API ini bukan kompatibel CLS.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat, kata sandi, dan bendera penyimpanan kunci.

public:
 X509Certificate2(System::String ^ fileName, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate2 (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (string fileName, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate2 (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate2 (string fileName, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (fileName As String, password As SecureString, keyStorageFlags As X509KeyStorageFlags)

Parameter

fileName
String

Nama file sertifikat.

password
SecureString

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

keyStorageFlags
X509KeyStorageFlags

Kombinasi bitwise dari nilai enumerasi yang mengontrol di mana dan bagaimana mengimpor sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Jika Anda membuat X509Certificate sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk fileName, X509Certificate dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat di dalam penyimpanan.

Berlaku untuk

X509Certificate2(String, ReadOnlySpan<Char>, X509KeyStorageFlags)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat, kata sandi, dan bendera penyimpanan kunci.

public X509Certificate2 (string fileName, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (string fileName, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
[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 X509Certificate2 (string fileName, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : string * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (fileName As String, password As ReadOnlySpan(Of Char), Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)

Parameter

fileName
String

Nama file sertifikat.

password
ReadOnlySpan<Char>

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

keyStorageFlags
X509KeyStorageFlags

Kombinasi bitwise dari nilai enumerasi yang mengontrol di mana dan bagaimana mengimpor sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (IL Disassembler), editor hex, atau hanya dengan membuka perakitan di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk fileName, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat di dalam penyimpanan.

Berlaku untuk

X509Certificate2(Byte[], String, X509KeyStorageFlags)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte, kata sandi, dan bendera penyimpanan kunci.

public:
 X509Certificate2(cli::array <System::Byte> ^ rawData, System::String ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
public X509Certificate2 (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (byte[] rawData, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate2 (byte[] rawData, string password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As Byte(), password As String, keyStorageFlags As X509KeyStorageFlags)

Parameter

rawData
Byte[]

Array byte yang berisi data dari sertifikat X.509.

password
String

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

keyStorageFlags
X509KeyStorageFlags

Kombinasi bitwise dari nilai enumerasi yang mengontrol di mana dan bagaimana mengimpor sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan array byte, kata sandi yang diperlukan untuk mengakses data sertifikat, dan bendera penyimpanan kunci. Ini digunakan dengan file PKCS12 (PFX) yang berisi kunci privat sertifikat. Memanggil konstruktor ini dengan kata sandi yang benar mendekripsi kunci privat dan menyimpannya ke Penyedia Layanan Kriptografi (CSP) MICROSOFT Cryptographic API.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (IL Disassembler), editor hex, atau hanya dengan membuka perakitan di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk rawData, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat di dalam penyimpanan.

Berlaku untuk

X509Certificate2(Byte[], SecureString, X509KeyStorageFlags)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Penting

API ini bukan kompatibel CLS.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte, kata sandi, dan bendera penyimpanan kunci.

public:
 X509Certificate2(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password, System::Security::Cryptography::X509Certificates::X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate2 (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (byte[] rawData, System.Security.SecureString? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[System.CLSCompliant(false)]
public X509Certificate2 (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
public X509Certificate2 (byte[] rawData, System.Security.SecureString password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * System.Security.SecureString * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As Byte(), password As SecureString, keyStorageFlags As X509KeyStorageFlags)

Parameter

rawData
Byte[]

Array byte yang berisi data dari sertifikat X.509.

password
SecureString

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

keyStorageFlags
X509KeyStorageFlags

Kombinasi bitwise dari nilai enumerasi yang mengontrol di mana dan cara mengimpor sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini digunakan dengan file PKCS12 (PFX) yang berisi kunci privat sertifikat. Memanggil konstruktor ini dengan kata sandi yang benar mendekripsi kunci privat dan menyimpannya ke Penyedia Layanan Kriptografi (CSP) API Kriptografi Microsoft.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (Il Disassembler), editor hex, atau hanya dengan membuka assembly di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk rawData, X509Certificate dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk

X509Certificate2(String, String)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat dan kata sandi yang digunakan untuk mengakses sertifikat.

public:
 X509Certificate2(System::String ^ fileName, System::String ^ password);
public X509Certificate2 (string fileName, string? password);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (string fileName, string? password);
public X509Certificate2 (string fileName, string password);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * string -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * string -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : string * string -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (fileName As String, password As String)

Parameter

fileName
String

Nama file sertifikat.

password
String

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan nama file sertifikat dan kata sandi yang diperlukan untuk mengakses sertifikat. Ini digunakan dengan file PKCS12 (PFX) yang berisi kunci privat sertifikat. Memanggil konstruktor ini dengan kata sandi yang benar mendekripsi kunci privat dan menyimpannya ke kontainer kunci.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (Il Disassembler), editor hex, atau hanya dengan membuka assembly di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk fileName, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk

X509Certificate2(String, SecureString)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Penting

API ini bukan kompatibel CLS.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat dan kata sandi.

public:
 X509Certificate2(System::String ^ fileName, System::Security::SecureString ^ password);
[System.CLSCompliant(false)]
public X509Certificate2 (string fileName, System.Security.SecureString? password);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (string fileName, System.Security.SecureString? password);
[System.CLSCompliant(false)]
public X509Certificate2 (string fileName, System.Security.SecureString password);
public X509Certificate2 (string fileName, System.Security.SecureString password);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (fileName As String, password As SecureString)

Parameter

fileName
String

Nama file sertifikat.

password
SecureString

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini digunakan dengan file PKCS12 (PFX) yang berisi kunci privat sertifikat. Memanggil konstruktor ini dengan kata sandi yang benar mendekripsi kunci privat dan menyimpannya ke kontainer kunci.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (Il Disassembler), editor hex, atau hanya dengan membuka assembly di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk fileName, X509Certificate dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk

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

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas dari data sertifikat, kata sandi, dan bendera penyimpanan kunci.

public X509Certificate2 (ReadOnlySpan<byte> rawData, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (ReadOnlySpan<byte> rawData, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
[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 X509Certificate2 (ReadOnlySpan<byte> rawData, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : ReadOnlySpan<byte> * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : ReadOnlySpan<byte> * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : ReadOnlySpan<byte> * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As ReadOnlySpan(Of Byte), password As ReadOnlySpan(Of Char), Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet)

Parameter

rawData
ReadOnlySpan<Byte>

Data sertifikat yang akan diproses.

password
ReadOnlySpan<Char>

Kata sandi yang diperlukan untuk mengakses data sertifikat.

keyStorageFlags
X509KeyStorageFlags

Kombinasi bitwise dari nilai enumerasi yang mengontrol di mana dan cara mengimpor sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat.

Berlaku untuk

X509Certificate2(Byte[], String)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte dan kata sandi.

public:
 X509Certificate2(cli::array <System::Byte> ^ rawData, System::String ^ password);
public X509Certificate2 (byte[] rawData, string? password);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (byte[] rawData, string? password);
public X509Certificate2 (byte[] rawData, string password);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * string -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * string -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : byte[] * string -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As Byte(), password As String)

Parameter

rawData
Byte[]

Array byte yang berisi data dari sertifikat X.509.

password
String

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan array byte dan kata sandi yang diperlukan untuk mengakses data sertifikat. Ini digunakan dengan file PKCS12 (PFX) yang berisi kunci privat sertifikat. Memanggil konstruktor ini dengan kata sandi yang benar mendekripsi kunci privat dan menyimpannya ke kontainer kunci.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (Il Disassembler), editor hex, atau hanya dengan membuka assembly di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk rawData, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk

X509Certificate2(Byte[], SecureString)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Penting

API ini bukan kompatibel CLS.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan array byte dan kata sandi.

public:
 X509Certificate2(cli::array <System::Byte> ^ rawData, System::Security::SecureString ^ password);
[System.CLSCompliant(false)]
public X509Certificate2 (byte[] rawData, System.Security.SecureString? password);
[System.CLSCompliant(false)]
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (byte[] rawData, System.Security.SecureString? password);
[System.CLSCompliant(false)]
public X509Certificate2 (byte[] rawData, System.Security.SecureString password);
public X509Certificate2 (byte[] rawData, System.Security.SecureString password);
[<System.CLSCompliant(false)>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.CLSCompliant(false)>]
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] * System.Security.SecureString -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As Byte(), password As SecureString)

Parameter

rawData
Byte[]

Array byte yang berisi data dari sertifikat X.509.

password
SecureString

Kata sandi yang diperlukan untuk mengakses data sertifikat X.509.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini digunakan dengan file PKCS12 (PFX) yang berisi kunci privat sertifikat. Memanggil konstruktor ini dengan kata sandi yang benar mendekripsi kunci privat dan menyimpannya ke kontainer kunci.

Penting

Jangan pernah mengodekan kata sandi secara permanen dalam kode sumber Anda. Kata sandi yang dikodekan secara permanen dapat diambil dari perakitan menggunakan Ildasm.exe (Il Disassembler), editor hex, atau hanya dengan membuka assembly di editor teks seperti Notepad.exe.

Jika Anda membuat X509Certificate sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk rawData, X509Certificate dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk

X509Certificate2(String)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan nama file sertifikat.

public:
 X509Certificate2(System::String ^ fileName);
public X509Certificate2 (string fileName);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (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 X509Certificate2 (string fileName);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : string -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : string -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (fileName As String)

Parameter

fileName
String

Nama file sertifikat.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan nama file sertifikat. Ini mendukung pengodean biner (DER) atau pengodean Base64.

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk fileName, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk

X509Certificate2(X509Certificate)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Menginisialisasi instans X509Certificate2 baru kelas menggunakan X509Certificate objek .

public:
 X509Certificate2(System::Security::Cryptography::X509Certificates::X509Certificate ^ certificate);
public X509Certificate2 (System.Security.Cryptography.X509Certificates.X509Certificate certificate);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (System.Security.Cryptography.X509Certificates.X509Certificate certificate);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : System.Security.Cryptography.X509Certificates.X509Certificate -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : System.Security.Cryptography.X509Certificates.X509Certificate -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (certificate As X509Certificate)

Parameter

certificate
X509Certificate

Sebuah objekX509Certificate.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Metode ini membuat instans X509Certificate2 baru kelas menggunakan X509Certificate objek .

Berlaku untuk

X509Certificate2(SerializationInfo, StreamingContext)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

This API supports obsolete formatter-based serialization. It should not be called or extended by application code.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan serialisasi yang ditentukan dan mengalirkan informasi konteks.

protected:
 X509Certificate2(System::Runtime::Serialization::SerializationInfo ^ info, System::Runtime::Serialization::StreamingContext context);
protected X509Certificate2 (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}")]
protected X509Certificate2 (System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : System.Runtime.Serialization.SerializationInfo * System.Runtime.Serialization.StreamingContext -> System.Security.Cryptography.X509Certificates.X509Certificate2
Protected Sub New (info As SerializationInfo, context As StreamingContext)

Parameter

info
SerializationInfo

Informasi serialisasi yang diperlukan untuk mendeserialisasi yang baru X509Certificate2.

context
StreamingContext

Informasi kontekstual tentang sumber aliran yang akan dideserialisasi.

Atribut

Pengecualian

Hanya .NET Core dan .NET 5+: Dalam semua kasus.

Berlaku untuk

X509Certificate2(ReadOnlySpan<Byte>)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas dari data sertifikat.

public:
 X509Certificate2(ReadOnlySpan<System::Byte> rawData);
public X509Certificate2 (ReadOnlySpan<byte> rawData);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (ReadOnlySpan<byte> rawData);
[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 X509Certificate2 (ReadOnlySpan<byte> rawData);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : ReadOnlySpan<byte> -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : ReadOnlySpan<byte> -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : ReadOnlySpan<byte> -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As ReadOnlySpan(Of Byte))

Parameter

rawData
ReadOnlySpan<Byte>

Data sertifikat yang akan diproses.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat.

Berlaku untuk

X509Certificate2(IntPtr)

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Menginisialisasi instans X509Certificate2 baru kelas menggunakan handel yang tidak terkelola.

public:
 X509Certificate2(IntPtr handle);
public X509Certificate2 (IntPtr handle);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (IntPtr handle);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : nativeint -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : nativeint -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (handle As IntPtr)

Parameter

handle
IntPtr

nativeint

Penunjuk ke konteks sertifikat dalam kode yang tidak dikelola. Struktur C disebut PCCERT_CONTEXT.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan handel untuk konteks sertifikat API Kriptografi Microsoft, PCCERT_CONTEXT. Perhatikan bahwa pemanggil langsung konstruktor ini memerlukan izin kode yang tidak dikelola.

Penting

Konstruktor membuat salinan konteks sertifikat. Jangan berasumsi bahwa struktur konteks yang Anda berikan ke konstruktor valid; mungkin telah dirilis. Anda bisa mendapatkan salinan struktur saat ini PCCERT_CONTEXT dari Handle properti , tetapi hanya berlaku selama masa X509Certificate2 pakai objek.

Berlaku untuk

X509Certificate2(Byte[])

Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs
Sumber:
X509Certificate2.cs

Perhatian

Loading certificate data through the constructor or Import is obsolete. Use X509CertificateLoader instead to load certificates.

Menginisialisasi instans X509Certificate2 baru kelas menggunakan informasi dari array byte.

public:
 X509Certificate2(cli::array <System::Byte> ^ rawData);
public X509Certificate2 (byte[] rawData);
[System.Runtime.Versioning.UnsupportedOSPlatform("browser")]
public X509Certificate2 (byte[] rawData);
[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 X509Certificate2 (byte[] rawData);
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<System.Runtime.Versioning.UnsupportedOSPlatform("browser")>]
new System.Security.Cryptography.X509Certificates.X509Certificate2 : byte[] -> System.Security.Cryptography.X509Certificates.X509Certificate2
[<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.X509Certificate2 : byte[] -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Sub New (rawData As Byte())

Parameter

rawData
Byte[]

Array byte yang berisi data dari sertifikat X.509.

Atribut

Pengecualian

Terjadi kesalahan dengan sertifikat. Contohnya:

  • File sertifikat tidak ada.

  • Sertifikat tidak valid.

  • Kata sandi sertifikat salah.

Keterangan

Konstruktor ini membuat objek baru X509Certificate2 menggunakan informasi sertifikat dari array byte. Array byte dapat berupa data berenkode biner (DER) atau X.509 berenkode Base64. Array byte juga dapat menjadi file bertanda tangan PKCS7 (Authenticode) ; sertifikat penanda tangan digunakan untuk membuat objek .

Jika Anda membuat X509Certificate2 sertifikat dengan menentukan penyimpanan file yang ditandatangani PKCS7 untuk rawData, X509Certificate2 dibuat untuk sertifikat yang menandatangani penyimpanan daripada untuk salah satu sertifikat dalam penyimpanan.

Berlaku untuk