
#use wml::openssl-macros area=docs page=SSL_CTX_set_psk_client_callback

<title>Documents, SSL_CTX_set_psk_client_callback(3)</title>

<h1>SSL_CTX_set_psk_client_callback(3)</h1>

#use wml::imp::generic

{:
## What's this? [[s|(<STRONG>[^<].+?)</A>(</STRONG><DD>)|$1$2|sg]]
[[s|<P>\s+<P>|<P>|sg]]
[[s|<P>\s+</|</|sg]]
[[s|<DD>\s*<DT>|<DD>&nbsp;<DT>|sg]]
[[s|<DD>\s*</DL>|<DD>&nbsp;</DL>|sg]]
[[s|\[|&#91;|sg]]
[[s|\]|&#93;|sg]]

<!-- INDEX BEGIN -->

<UL>

	<LI><A HREF="#NAME">NAME</A>
	<LI><A HREF="#SYNOPSIS">SYNOPSIS</A>
	<LI><A HREF="#DESCRIPTION">DESCRIPTION</A>
	<LI><A HREF="#NOTES">NOTES</A>
	<LI><A HREF="#RETURN_VALUES">RETURN VALUES</A>
</UL>
<!-- INDEX END -->

<HR>
<P>
<HR>
<H1><A NAME="NAME">NAME</A></H1>
<P>
SSL_CTX_set_psk_client_callback, SSL_set_psk_client_callback - set PSK
client callback

</P>
<P>
<HR>
<H1><A NAME="SYNOPSIS">SYNOPSIS</A></H1>
<PRE> #include &lt;openssl/ssl.h&gt;
</PRE>
<PRE> void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx,
        unsigned int (*callback)(SSL *ssl, const char *hint,
        char *identity, unsigned int max_identity_len,
        unsigned char *psk, unsigned int max_psk_len));
 void SSL_set_psk_client_callback(SSL *ssl,
        unsigned int (*callback)(SSL *ssl, const char *hint,
        char *identity, unsigned int max_identity_len,
        unsigned char *psk, unsigned int max_psk_len));
</PRE>
<P>
<HR>
<H1><A NAME="DESCRIPTION">DESCRIPTION</A></H1>
<P>
A client application must provide a callback function which is called when
the client is sending the ClientKeyExchange message to the server.

</P>
<P>
The purpose of the callback function is to select the PSK identity and the
pre-shared key to use during the connection setup phase.

</P>
<P>
The callback is set using functions
<CODE>SSL_CTX_set_psk_client_callback()</CODE> or
<CODE>SSL_set_psk_client_callback().</CODE> The callback function is given
the connection in parameter <STRONG>ssl</STRONG>, a <STRONG>NULL</STRONG>-terminated PSK identity hint sent by the server in parameter <STRONG>hint</STRONG>, a buffer <STRONG>identity</STRONG> of length <STRONG>max_identity_len</STRONG> bytes where the the resulting
<STRONG>NULL</STRONG>-terminated identity is to be stored, and a buffer <STRONG>psk</STRONG> of length <STRONG>max_psk_len</STRONG> bytes where the resulting pre-shared key is to be stored.

</P>
<P>
<HR>
<H1><A NAME="NOTES">NOTES</A></H1>
<P>
Note that parameter <STRONG>hint</STRONG> given to the callback may be <STRONG>NULL</STRONG>.

</P>
<P>
<HR>
<H1><A NAME="RETURN_VALUES">RETURN VALUES</A></H1>
<P>
Return values from the client callback are interpreted as follows:

</P>
<P>
On success (callback found a PSK identity and a pre-shared key to use) the
length (&gt; 0) of <STRONG>psk</STRONG> in bytes is returned.

</P>
<P>
Otherwise or on errors callback should return 0. In this case the
connection setup fails.

</P>
:}

