[#PEM_write_PKCS8PrivateKey_nid]
= PEM&lowbar;write&lowbar;PKCS8PrivateKey&lowbar;nid
:mrdocs:

Write a private key as PEM PKCS&num;8 using a PKCS&num;5 v1&period;5 &sol; PKCS&num;12 PBE NID&period;

== Synopsis

Declared in `&lt;openssl&sol;pem&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
PEM&lowbar;write&lowbar;PKCS8PrivateKey&lowbar;nid(
    FILE* fp,
    xref:EVP_PKEY.adoc[EVP&lowbar;PKEY] const* x,
    int nid,
    char const* kstr,
    int klen,
    xref:pem_password_cb.adoc[pem&lowbar;password&lowbar;cb]* cb,
    void* u);
----

== Return Value

1 on success, or 0 on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *fp*
| FILE to write to&period;
| *x*
| Private key to encode&period;
| *nid*
| NID of the PBE algorithm OBJECT IDENTIFIER&period;
| *kstr*
| Optional passphrase&semi; if NULL, `cb` is used when encryption requires one&period;
| *klen*
| Length of `kstr` when provided&period;
| *cb*
| Password callback when a passphrase is needed, or NULL&period;
| *u*
| Application data passed to `cb&period;`
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
