X509CertificateLoader.LoadPkcs12 方法

定義

多載

LoadPkcs12(Byte[], String, X509KeyStorageFlags, Pkcs12LoaderLimits)

以 PKCS#12 PFX 的形式載入所提供的數據,並擷取憑證。

LoadPkcs12(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, X509KeyStorageFlags, Pkcs12LoaderLimits)

以 PKCS#12 PFX 的形式載入所提供的數據,並擷取憑證。

LoadPkcs12(Byte[], String, X509KeyStorageFlags, Pkcs12LoaderLimits)

來源:
X509CertificateLoader.cs

以 PKCS#12 PFX 的形式載入所提供的數據,並擷取憑證。

public static System.Security.Cryptography.X509Certificates.X509Certificate2 LoadPkcs12 (byte[] data, string? password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet, System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits? loaderLimits = default);
static member LoadPkcs12 : byte[] * string * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags * System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Shared Function LoadPkcs12 (data As Byte(), password As String, Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet, Optional loaderLimits As Pkcs12LoaderLimits = Nothing) As X509Certificate2

參數

data
Byte[]

要載入的數據。

password
String

解密 PFX 內容的密碼。

keyStorageFlags
X509KeyStorageFlags

列舉值的位元組合,控制與傳回憑證相關聯之私鑰的位置和方式。

loaderLimits
Pkcs12LoaderLimits

載入 PFX 時要套用的限制。 預設值 null 值相當於 Defaults

傳回

載入的憑證。

例外狀況

data null

keyStorageFlags 包含無效的值或值組合。

keyStorageFlags 包含對目前平臺無效的值。

PKCS#12/PFX 違反一或多個 loaderLimits條件約束。

載入 PKCS#12/PFX 時發生錯誤。

備註

PKCS#12/PFX 可以包含多個憑證。 使用憑證出現在 LoadPkcs12Collection(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, X509KeyStorageFlags, Pkcs12LoaderLimits)結果中的排序,這個方法會傳回 HasPrivateKeytrue的第一個憑證。 如果沒有憑證具有相關聯的私鑰,則會傳回第一個憑證。 如果 PKCS#12/PFX 不包含任何憑證,則會擲回 CryptographicException

適用於

LoadPkcs12(ReadOnlySpan<Byte>, ReadOnlySpan<Char>, X509KeyStorageFlags, Pkcs12LoaderLimits)

來源:
X509CertificateLoader.cs

以 PKCS#12 PFX 的形式載入所提供的數據,並擷取憑證。

public static System.Security.Cryptography.X509Certificates.X509Certificate2 LoadPkcs12 (ReadOnlySpan<byte> data, ReadOnlySpan<char> password, System.Security.Cryptography.X509Certificates.X509KeyStorageFlags keyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet, System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits? loaderLimits = default);
static member LoadPkcs12 : ReadOnlySpan<byte> * ReadOnlySpan<char> * System.Security.Cryptography.X509Certificates.X509KeyStorageFlags * System.Security.Cryptography.X509Certificates.Pkcs12LoaderLimits -> System.Security.Cryptography.X509Certificates.X509Certificate2
Public Shared Function LoadPkcs12 (data As ReadOnlySpan(Of Byte), password As ReadOnlySpan(Of Char), Optional keyStorageFlags As X509KeyStorageFlags = System.Security.Cryptography.X509Certificates.X509KeyStorageFlags.DefaultKeySet, Optional loaderLimits As Pkcs12LoaderLimits = Nothing) As X509Certificate2

參數

data
ReadOnlySpan<Byte>

要載入的數據。

password
ReadOnlySpan<Char>

解密 PFX 內容的密碼。

keyStorageFlags
X509KeyStorageFlags

列舉值的位元組合,控制與傳回憑證相關聯之私鑰的位置和方式。

loaderLimits
Pkcs12LoaderLimits

載入 PFX 時要套用的限制。 預設值 null 值相當於 Defaults

傳回

載入的憑證。

例外狀況

data null

keyStorageFlags 包含無效的值或值組合。

keyStorageFlags 包含對目前平臺無效的值。

PKCS#12/PFX 違反一或多個 loaderLimits條件約束。

載入 PKCS#12/PFX 時發生錯誤。

備註

PKCS#12/PFX 可以包含多個憑證。 使用憑證出現在 LoadPkcs12Collection(Byte[], String, X509KeyStorageFlags, Pkcs12LoaderLimits)結果中的排序,這個方法會傳回 HasPrivateKeytrue的第一個憑證。 如果沒有憑證具有相關聯的私鑰,則會傳回第一個憑證。 如果 PKCS#12/PFX 不包含任何憑證,則會擲回 CryptographicException

適用於