Mentalis.org Security Library documentation

Certificate.ToPfxFile Method 

Saves the Certificate as a PFX encoded file.

[Visual Basic]
Public Sub ToPfxFile( _
   ByVal filename As String, _
   ByVal password As String, _
   ByVal withPrivateKeys As Boolean, _
   ByVal withParents As Boolean _
)
[C#]
public void ToPfxFile(
   string filename,
   string password,
   bool withPrivateKeys,
   bool withParents
);

Parameters

filename
The filename of the new PFX file.
password
The password to use when encrypting the private keys.
withPrivateKeys
true if the private keys should be exported [if possible], false otherwise.
withParents
true if the parent certificates should be exported too [if possible], false otherwise.

Remarks

If the specified file already exists, the method will throw an exception.

Exceptions

Exception TypeCondition
ArgumentNullExceptionfilename or password is a null reference (Nothing in Visual Basic).
IOExceptionAn error occurs while writing the data to the file.
CertificateExceptionAn error occurs while exporting the certificate store
-or-
an error occurs while building the certificate chain
-or-
an error occurs while creating the store
-or-
an error occurs while adding the certificate to the store.

See Also

Certificate Class | Certificate Members | Org.Mentalis.Security.Certificates Namespace