SSL_SET_SESSION_SECRET_CB(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… SSL_SET_SESSION_SECRET_CB β€” set the session secret callback ✨

okay so this is SSL_SET_SESSION_SECRET_CB(3ossl), bestie β€” it lives in the OpenSSL manual fam, and it's genuinely a niche little icon. Let's get into it 🫢


🌸 NAME 🌸

SSL_set_session_secret_cb, tls_session_secret_cb_fn β€” set the session secret callback πŸ’–


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

typedef int (*tls_session_secret_cb_fn)(SSL *s, void *secret, int *secret_len,
                                        STACK_OF(SSL_CIPHER) *peer_ciphers,
                                        const SSL_CIPHER **cipher, void *arg);

int SSL_set_session_secret_cb(SSL *s,
                              tls_session_secret_cb_fn session_secret_cb,
                              void *arg);

πŸ¦‹ DESCRIPTION πŸ¦‹

So SSL_set_session_secret_cb() does exactly what the girlies expect: it sets the session secret callback to be used (session_secret_cb), plus an optional argument (arg) that gets passed along to that callback whenever it's called. Literally just wiring it up πŸ’…

⚠️ but like, listen β€” this is only useful for an implementation of EAP-FAST (RFC4851). no cap.

And here's the part that's lowkey a big deal: the presence of the callback also modifies the internal OpenSSL TLS state machine to match the modified TLS behaviour as described in RFC4851. Sooo… yeah. This callback should not be used except when implementing EAP-FAST. periodt. do not mess with it otherwise πŸ™ˆ


πŸŽ€ what the callback actually has to do πŸŽ€

The callback is expected to set the master secret to be used by filling in the data pointed to by *secret. Think of it like: here's the buffer, go fill it in, bestie ✍️

The size of the secret buffer is initially available in *secret_len, and the callback may update it β€” but it must not be larger than the initial value. respect the bounds or perish πŸ’€

🌈 on the server side

The set of ciphersuites offered by the peer is provided in the peer_ciphers stack. Optionally, the callback may select the preferred ciphersuite by setting it in *cipher β€” your call, main character energy πŸ‘‘

🧚 on the client side

The peer_ciphers stack will always be NULL. Always. Not sometimes-null, not maybe-null, NULL 🫠

The callback may still specify the preferred cipher in *cipher, and this will be associated with the SSL_SESSION β€” but (and this is the important bit) it does not affect the ciphersuite selected by the server. so fr fr, don't expect it to change what the server picks πŸ’…

πŸ“ and one more thing

The callback is also supplied with an additional argument in arg, which is literally the argument that was provided to the original SSL_set_session_secret_cb() call. full circle moment πŸ”₯


πŸ‘‘ RETURN VALUES πŸ‘‘

  • SSL_set_session_secret_cb() β€” returns 1 on success and 0 on failure. slay ✨
  • the callback itself β€” if it returns 1, that indicates it has successfully set the secret πŸ’– a return value of 0 indicates that the secret has not been set β€” and on the client, that will cause an immediate abort of the handshake 😭 like, full stop, handshake over.

🌸 SEE ALSO 🌸

go read those too, iykyk 🫢


Copyright 2024 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at <https://www.openssl.org/source/license.html>.


so yeah, that's the whole vibe check πŸ’… this page is from OpenSSL 3.5.0, dated 2026-09-25, and it's filed under SSL_SET_SESSION_SECRET_CB(3ossl) β€” go forth and only implement EAP-FAST with it, bestie πŸ˜­πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from