Creates a new instance of the Certificate class by opening a PFX file and retrieving the first certificate from it.

Namespace: LLCryptoLib.Security.Certificates
Assembly: LLCryptoLib (in LLCryptoLib.dll) Version: 2.0.1024.0 (2.0.1024)

Syntax

C#
public static Certificate CreateFromPfxFile(
	string file,
	string password,
	bool exportable,
	KeysetLocation location
)
Visual Basic
Public Shared Function CreateFromPfxFile ( _
	file As String, _
	password As String, _
	exportable As Boolean, _
	location As KeysetLocation _
) As Certificate
Visual C++
public:
static Certificate^ CreateFromPfxFile(
	String^ file, 
	String^ password, 
	bool exportable, 
	KeysetLocation location
)

Parameters

file
Type: System..::..String
The full path to the PFX file.
password
Type: System..::..String
The password used to encrypt the private key.
exportable
Type: System..::..Boolean
true if the private keys associated with the certificates should be marked as exportable, false otherwise.
location
Type: LLCryptoLib.Security.Certificates..::..KeysetLocation
One of the KeysetLocation values.

Return Value

One of the certificates in the PFX file.

Remarks

Warning: this method returns the first Certificate it can find in the specified PFX file. Care should be taken to verify whether the correct Certificate instance is returned when using PFX files that contain more than one certificate. For more fine-grained control over which certificate is returned, use the CertificateStore.CreateFromPfxFile method to instantiate a CertificateStore object and then use the CertificateStore.FindCertificateBy*** methods.

Exceptions

ExceptionCondition
System..::..ArgumentNullExceptionfile or password is a null reference (Nothing in Visual Basic).
LLCryptoLib.Security.Certificates..::..CertificateExceptionAn error occurs while loading certificates from the specified file.
System..::..ArgumentExceptionpassword is invalid.

See Also