X509CertificateLoader.LoadPkcs12FromFile 方法

定義

多載

LoadPkcs12FromFile(String, ReadOnlySpan<Char>, X509KeyStorageFlags, Pkcs12LoaderLimits)

開啟指定的檔案、將內容讀取為 PKCS#12 PFX,並擷取憑證。

LoadPkcs12FromFile(String, String, X509KeyStorageFlags, Pkcs12LoaderLimits)

開啟指定的檔案、將內容讀取為 PKCS#12 PFX,並擷取憑證。

LoadPkcs12FromFile(String, ReadOnlySpan<Char>, X509KeyStorageFlags, Pkcs12LoaderLimits)

來源:
X509CertificateLoader.cs

開啟指定的檔案、將內容讀取為 PKCS#12 PFX,並擷取憑證。

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

參數

path
String

要開啟之檔案的路徑。

password
ReadOnlySpan<Char>

解密 PFX 內容的密碼。

keyStorageFlags
X509KeyStorageFlags

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

loaderLimits
Pkcs12LoaderLimits

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

傳回

載入的憑證。

例外狀況

path null

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

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

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

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

載入指定的檔案時發生錯誤。

備註

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

適用於

LoadPkcs12FromFile(String, String, X509KeyStorageFlags, Pkcs12LoaderLimits)

來源:
X509CertificateLoader.cs

開啟指定的檔案、將內容讀取為 PKCS#12 PFX,並擷取憑證。

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

參數

path
String

要開啟之檔案的路徑。

password
String

解密 PFX 內容的密碼。

keyStorageFlags
X509KeyStorageFlags

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

loaderLimits
Pkcs12LoaderLimits

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

傳回

載入的憑證。

例外狀況

path null

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

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

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

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

載入指定的檔案時發生錯誤。

備註

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

適用於