PEM_write_PKCS8PrivateKey

Write a private key as PEM PKCS#8 EncryptedPrivateKeyInfo (PKCS#5 v2.0).

Synopsis

Declared in <openssl/pem.h>

int
PEM_write_PKCS8PrivateKey(
    FILE* fp,
    EVP_PKEY const* x,
    EVP_CIPHER const* enc,
    char const* kstr,
    int klen,
    pem_password_cb* cd,
    void* u);

Return Value

1 on success, or 0 on failure.

Parameters

NameDescription
fpFILE to write to.
xPrivate key to encode.
encCipher used at the PKCS#8 level, or NULL for unencrypted PrivateKeyInfo.
kstrOptional passphrase; if NULL and enc is set, cd is used.
klenLength of kstr when provided.
cdPassword callback when a passphrase is needed, or NULL.
uApplication data passed to cd.