NPKIExportUserKey

Exports a private key and the corresponding certificates for the currently logged-in user in Personal Information Exchange Syntax (PFX) format (formerly NWPKIExportUserKey).

Syntax

    #include "npki.h"
    
    NWRCODE NPKIExportUserKey(
       const NPKIContext    context,
       const unicode       *nickname,
       const unicode       *password,
       const nuint32        flags,
       pnuint32            *pfxSize,
       nuint8 const        **pfx);
    

Parameters

context
(IN) Specifies the NPKI context for the request.
nickname
(IN) Specifies the certificate nickname that identifies which private key and certificates are to be exported. nickname must be a valid certificate nickname for the currently logged-in user in the current tree.
password
(IN) Specifies the password to use to encrypt the private key and certificate.
flags
(IN) Specifies options for exporting the user key and certificates. The flags currently defined are:PKI_CHAIN_CERTIFICATE—Exports the chain of certificates in the certification path along with the specified user certificate.
pfxSize
(OUT) Points to the size of the exported data.
pfx
(OUT) Points to the PKCS #12 encoded data.

Return Values

Returns 0 if successful, or an eDirectory, NICI or PKI error code if not successful.

PKI NCP Calls

0x2222 93 09 Read Key

Remarks

The key and certificate are encrypted using the input password as specified in the PKCS #12. For a sample implementation of this task, see ExportUserCert.