PEM_write_bio_PrivateKey

Write a private key to a BIO as PEM, preferring PKCS#8 EncryptedPrivateKeyInfo.

Synopsis

Declared in <openssl/pem.h>

int
PEM_write_bio_PrivateKey(
    BIO* bp,
    EVP_PKEY const* x,
    EVP_CIPHER const* enc,
    unsigned char const* kstr,
    int klen,
    pem_password_cb* cb,
    void* u);

Return Value

1 on success, or 0 on failure.

Parameters

NameDescription
bpBIO to write to.
xPrivate key to encode.
encCipher for PKCS#8 encryption, or NULL for unencrypted PrivateKeyInfo.
kstrOptional passphrase bytes; if NULL and enc is set, cb is used.
klenLength of kstr when provided.
cbPassword callback when a passphrase is needed, or NULL.
uApplication data passed to cb.