[#PEM_ASN1_write]
= PEM&lowbar;ASN1&lowbar;write
:mrdocs:

Encode an ASN&period;1 object with `i2d` and write it as PEM to a FILE&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
int
PEM&lowbar;ASN1&lowbar;write(
    xref:i2d_of_void.adoc[i2d&lowbar;of&lowbar;void]* i2d,
    char const* name,
    FILE* fp,
    void const* x,
    xref:EVP_CIPHER-07.adoc[EVP&lowbar;CIPHER] const* enc,
    unsigned char const* kstr,
    int klen,
    xref:pem_password_cb.adoc[pem&lowbar;password&lowbar;cb]* callback,
    void* u);
----

== Return Value

1 on success, or 0 on failure&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *i2d*
| ASN&period;1 encode callback for the object type&period;
| *name*
| PEM type label used on the BEGIN&sol;END lines&period;
| *fp*
| FILE to write to&period;
| *x*
| Object to encode&period;
| *enc*
| Optional cipher for traditional PEM encryption, or NULL&period;
| *kstr*
| Optional key material for `enc,` or NULL to prompt via `callback&period;`
| *klen*
| Length of `kstr` in bytes&period;
| *callback*
| Password callback when encrypting without `kstr,` or NULL&period;
| *u*
| Application data passed to `callback&period;`
|===


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