[#OSSL_ENCODER_CTX_new_for_pkey]
= OSSL&lowbar;ENCODER&lowbar;CTX&lowbar;new&lowbar;for&lowbar;pkey
:mrdocs:

Create an encoder context preconfigured to encode an EVP&lowbar;PKEY&period;

== Synopsis

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

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
xref:OSSL_ENCODER_CTX.adoc[OSSL&lowbar;ENCODER&lowbar;CTX]*
OSSL&lowbar;ENCODER&lowbar;CTX&lowbar;new&lowbar;for&lowbar;pkey(
    xref:EVP_PKEY.adoc[EVP&lowbar;PKEY] const* pkey,
    int selection,
    char const* output&lowbar;type,
    char const* output&lowbar;struct,
    char const* propquery);
----

== Description

Performs an implicit encoder fetch suitable for `pkey,` which is more useful than calling OSSL&lowbar;ENCODER&lowbar;CTX&lowbar;new() alone&period; The returned context may have zero encoders if none matched&semi; check with OSSL&lowbar;ENCODER&lowbar;CTX&lowbar;get&lowbar;num&lowbar;encoders()&period;

== Return Value

New encoder context, or NULL on error&semi; free with OSSL&lowbar;ENCODER&lowbar;CTX&lowbar;free()&period;

== Parameters

[cols="1,4"]
|===
| Name| Description
| *pkey*
| Assigned public or private key to encode&period;
| *selection*
| OSSL&lowbar;KEYMGMT&lowbar;SELECT&lowbar;&ast; mask for components to encode&period;
| *output&lowbar;type*
| Desired ending output type (for example &quot;DER&quot; or &quot;PEM&quot;)&period;
| *output&lowbar;struct*
| Desired output structure name (for example &quot;pkcs8&quot;), or NULL&period;
| *propquery*
| Optional property query for encoder fetching, or NULL&period;
|===


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