---
name: "libressl-SSL_set_psk_use_session_callback"
section: "3"
platform: "linux"
package: "libressl"
version: "4.4.0-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/libressl-SSL_set_psk_use_session_callback"
---

# libressl-SSL\_set\_psk\_use\_session\_callback(3)

set TLS pre-shared key client callback

## NAME

**SSL\_set\_psk\_use\_session\_callback**, **SSL\_psk\_use\_session\_cb\_func** – set TLS pre-shared key client callback

## SYNOPSIS

SSL Library (libssl, -lssl) libcrypto

**#include \<openssl/ssl.h\>**

*typedef* *int*\

**(\*SSL\_psk\_use\_session\_cb\_func)**(*SSL \*ssl*, *const EVP\_MD \*md*, *const unsigned char \*\*id*, *size\_t \*idlen*, *SSL\_SESSION \*\*session*);

*void*\

**SSL\_set\_psk\_use\_session\_callback**(*SSL \*ssl*, *SSL\_psk\_use\_session\_cb\_func cb*);

## DESCRIPTION

LibreSSL provides the stub function **SSL\_set\_psk\_use\_session\_callback**() to allow compiling application programs that contain optional support for TLSv1.3 pre-shared keys.

LibreSSL does not support TLS pre-shared keys, and no action occurs when **SSL\_set\_psk\_use\_session\_callback**() is called. In particular, both arguments are ignored. During session negotiation, LibreSSL never calls the callback *cb* and always behaves as if that callback succeeded and set the \**session* pointer to NULL. That is, LibreSSL never sends a pre-shared key to the server and never aborts the handshake for lack of a pre-shared key.

With OpenSSL, a client application wishing to use TLSv1.3 pre-shared keys can install a callback function *cb* using **SSL\_set\_psk\_use\_session\_callback**(). The OpenSSL library may call *cb* once or twice during session negotiation. If the callback fails, OpenSSL aborts connection setup. If the callback succeeds but sets the \**session* pointer to NULL, OpenSSL continues the handshake but does not send a pre-shared key to the server.

## RETURN VALUES

The **SSL\_psk\_use\_session\_cb\_func**() callback is expected to return 1 on success or 0 on failure.

## HISTORY

**SSL\_set\_psk\_use\_session\_callback**() and **SSL\_psk\_use\_session\_cb\_func**() first appeared in OpenSSL 1.1.1 and have been available since OpenBSD 7.0.
