Export (0) Print
Expand All
Expand Minimize

PFXExportCertStore function

The PFXExportCertStore function exports the certificates and, if available, the associated private keys from the referenced certificate store. This is an old function kept for compatibility with Internet Explorer 4.0 clients. New applications should use the PfxExportCertStoreEx function that provides enhanced private key security.

Syntax


BOOL WINAPI PFXExportCertStore(
  _In_     HCERTSTORE hStore,
  _Inout_  CRYPT_DATA_BLOB *pPFX,
  _In_     LPCWSTR szPassword,
  _In_     DWORD dwFlags
);

Parameters

hStore [in]

Handle of the certificate store containing the certificates to be exported.

pPFX [in, out]

A pointer to a CRYPT_DATA_BLOB structure to contain the PFX packet with the exported certificates and keys. If pPFX->pbData is NULL, the function calculates the number of bytes needed for the encoded BLOB and returns this in pPFX->cbData. When the function is called with pPFX->pbData pointing to an allocated buffer of the needed size, the function copies the encoded bytes into the buffer and updates pPFX->cbData with the encode byte length.

szPassword [in]

String password used to encrypt and verify the PFX packet. When you have finished using the password, clear the password from memory by calling the SecureZeroMemory function. For more information about protecting passwords, see Handling Passwords.

dwFlags [in]

Flag values can be set to any combination of the following.

ValueMeaning
EXPORT_PRIVATE_KEYS

Private keys are exported as well as the certificates.

REPORT_NO_PRIVATE_KEY

If a certificate is encountered that has no associated private key, the function returns FALSE with the last error set to either CRYPT_E_NOT_FOUND or NTE_NO_KEY.

REPORT_NOT_ABLE_TO_EXPORT_PRIVATE_KEY

If a certificate is encountered that has a non-exportable private key, the function returns FALSE and the last error set to NTE_BAD_KEY, NTE_BAD_KEY_STATE, or NTE_PERM.

 

Return value

Returns TRUE (nonzero) if the function succeeds, and FALSE (zero) if the function fails. For extended error information, call GetLastError.

Requirements

Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]

Header

Wincrypt.h

Library

Crypt32.lib

DLL

Crypt32.dll

See also

PFXExportCertStoreEx
PFXImportCertStore

 

 

Community Additions

ADD
Show:
© 2014 Microsoft