SSL_SET_QUIC_TLS_CBS(3ossl)
okay bestie, welcome to SSL_SET_QUIC_TLS_CBS(3ossl) β the OpenSSL manual page thatβs all about letting the OpenSSL TLS implementation do the TLS thing for a third party QUIC implementation, and itβs genuinely such a serve. π
β¨
β¨ NAME β¨
The whole crew on this page is:
OSSL_FUNC_SSL_QUIC_TLS_crypto_send_fnOSSL_FUNC_SSL_QUIC_TLS_crypto_recv_rcd_fnOSSL_FUNC_SSL_QUIC_TLS_crypto_release_rcd_fnOSSL_FUNC_SSL_QUIC_TLS_yield_secret_fnOSSL_FUNC_SSL_QUIC_TLS_got_transport_params_fnOSSL_FUNC_SSL_QUIC_TLS_alert_fnSSL_set_quic_tls_cbsSSL_set_quic_tls_transport_paramsSSL_set_quic_tls_early_data_enabled
Short version: use the OpenSSL TLS implementation for a third party QUIC implementation. π«Ά
π¦ SYNOPSIS π¦
#include <openssl/ssl.h>
/* QUIC TLS callbacks available via an OSSL_DISPATCH table */
/* Function id: OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_SEND */
typedef int (*OSSL_FUNC_SSL_QUIC_TLS_crypto_send_fn)(SSL *s,
const unsigned char *buf,
size_t buf_len,
size_t *consumed,
void *arg);
/* Function id: OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RECV_RCD */
typedef int (*OSSL_FUNC_SSL_QUIC_TLS_crypto_recv_rcd_fn)(SSL *s,
const unsigned char **buf,
size_t *bytes_read,
void *arg);
/* Function id: OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RELEASE_RCD */
typedef int (*OSSL_FUNC_SSL_QUIC_TLS_crypto_release_rcd_fn)(SSL *,
size_t bytes_read,
void *arg);
/* Function id: OSSL_FUNC_SSL_QUIC_TLS_YIELD_SECRET */
typedef int (*OSSL_FUNC_SSL_QUIC_TLS_yield_secret_fn)(SSL *s,
uint32_t prot_level,
int direction,
const unsigned char *secret,
size_t secret_len,
void *arg);
/* Function id: OSSL_FUNC_SSL_QUIC_TLS_GOT_TRANSPORT_PARAMS */
typedef int (*OSSL_FUNC_SSL_QUIC_TLS_got_transport_params_fn)(SSL *s,
const unsigned char *params,
size_t params_len,
void *arg);
/* Function id: OSSL_FUNC_SSL_QUIC_TLS_ALERT */
typedef int (*OSSL_FUNC_SSL_QUIC_TLS_alert_fn)(SSL *s,
unsigned char alert_code,
void *arg);
int SSL_set_quic_tls_cbs(SSL *s, const OSSL_DISPATCH *qtdis, void *arg);
int SSL_set_quic_tls_transport_params(SSL *s,
const unsigned char *params,
size_t params_len);
int SSL_set_quic_tls_early_data_enabled(SSL *s, int enabled);
π DESCRIPTION π
So hereβs the tea: SSL_set_quic_tls_cbs() can replace the standard TLS record layer with a custom record layer for a third party QUIC implementation. For the given SSL object s, you supply a set of callbacks in an OSSL_DISPATCH table via qtdis. The arg parameter gets passed as an argument whenever the various callbacks are called. π«Ά
An OSSL_DISPATCH table is an array of OSSL_DISPATCH entries, where each entry is a function id and a function pointer. Terminate the array with an empty entry β that means a 0 function id and a NULL function pointer. No cap. π§
Calling SSL_set_quic_tls_cbs() switches off the SSL_OP_ENABLE_MIDDLEBOX_COMPAT option (if it is set). See SSL_set_options(3). It also sets the minimum TLS protocol version to TLS1_3_VERSION. Calling this function with anything other than a TLS connection SSL object is an error. π¨
Here are the callbacks and what theyβre giving:
OSSL_FUNC_SSL_QUIC_TLS_crypto_send_fnβ function idOSSL_FUNC_SSL_QUIC_TLS_CRYPTO_SEND. Called when CRYPTO frame data should be sent to the peer. The data to send is supplied in the bufferbuf, which is of lengthbuf_len. The callback may choose to consume less data than was supplied in the buffer. On successful completion of the callback, theconsumedparameter should be populated with the amount of data that the callback consumed. This should be less than or equal to the value inbuf_len. CRYPTO data should be sent using the most recent write encryption level set via theOSSL_FUNC_SSL_QUIC_TLS_yield_secret_fncallback (if it has been called). π₯OSSL_FUNC_SSL_QUIC_TLS_crypto_recv_rcd_fnβ function idOSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RECV_RCD. Used to receive CRYPTO frame data from the peer. When OpenSSL wants to read data from the peer, this callback is called. The callback should populate*bufwith a pointer to a buffer containing CRYPTO data that has been received from the peer. The size of the buffer should be populated in*bytes_read. The buffer should remain valid until OpenSSL calls theOSSL_FUNC_SSL_QUIC_TLS_crypto_release_rcd_fncallback. CRYPTO frame data is assumed to have been decrypted using the most recent read protection level set via theyield_secret_cbcallback (if it has been called). πOSSL_FUNC_SSL_QUIC_TLS_crypto_release_rcd_fnβ function idOSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RELEASE_RCD. Called when data previously read viaOSSL_FUNC_SSL_QUIC_TLS_crypto_recv_rcd_fnis no longer required. Thebytes_readargument is always equal to the size of the buffer previously provided in thecrypto_receive_rcd_cbcallback. Only one record at a time will ever be read by OpenSSL. π«‘OSSL_FUNC_SSL_QUIC_TLS_yield_secret_fnβ function idOSSL_FUNC_SSL_QUIC_TLS_YIELD_SECRET. Called when a new secret has been established. Theprot_levelargument identifies the TLS protection level and will be one ofOSSL_RECORD_PROTECTION_LEVEL_NONE,OSSL_RECORD_PROTECTION_LEVEL_EARLY,OSSL_RECORD_PROTECTION_LEVEL_HANDSHAKEorOSSL_RECORD_PROTECTION_LEVEL_APPLICATION. Thedirectionwill either be0(for the read secret) or1(for the write secret). The secret itself will be in the buffer pointed to bysecret, and the buffer will be of lengthsecret_len. πOSSL_FUNC_SSL_QUIC_TLS_got_transport_params_fnβ function idOSSL_FUNC_SSL_QUIC_TLS_GOT_TRANSPORT_PARAMS. Called when transport parameters have been received from the peer. The parameters are held in theparamsbuffer, which is of lengthparams_len. πΈOSSL_FUNC_SSL_QUIC_TLS_alert_fnβ function idOSSL_FUNC_SSL_QUIC_TLS_ALERT. Called when OpenSSL is attempting to send an alert to the peer. The code for the alert is supplied inalert_code. π¨
SSL_set_quic_tls_transport_params() is used to set the transport parameters to be sent by this endpoint. The parameters are in the params buffer, which should be of length params_len. The buffer containing the parameters should remain valid until after the parameters have been sent. This function must have been called by the time the transport parameters need to be sent. For a client this will be before the connection has been initiated. For a server this might typically occur during the got_transport_params_cb. π
SSL_set_quic_tls_early_data_enabled() is used to enable the 0-RTT feature for a third party QUIC implementation. β¨
π RETURN VALUES π
These functions return 1 on success and 0 on failure.
All of the callbacks should also return 1 on success and 0 on failure. A failure response is fatal to the connection, so bestie, do not treat a 0 like a casual vibe check. π
π§ EXAMPLES π§
A call to SSL_set_quic_tls_cbs() might look something like the following, given suitable definitions of the various callback functions:
const OSSL_DISPATCH qtdis[] = {
{OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_SEND, (void (*)(void))crypto_send_cb},
{OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RECV_RCD,
(void (*)(void))crypto_recv_rcd_cb},
{OSSL_FUNC_SSL_QUIC_TLS_CRYPTO_RELEASE_RCD,
(void (*)(void))crypto_release_rcd_cb},
{OSSL_FUNC_SSL_QUIC_TLS_YIELD_SECRET,
(void (*)(void))yield_secret_cb},
{OSSL_FUNC_SSL_QUIC_TLS_GOT_TRANSPORT_PARAMS,
(void (*)(void))got_transport_params_cb},
{OSSL_FUNC_SSL_QUIC_TLS_ALERT, (void (*)(void))alert_cb},
{0, NULL}
};
if (!SSL_set_quic_tls_cbs(ssl, qtdis, NULL))
goto err;
β HISTORY β
These functions were added in OpenSSL 3.5. β
π COPYRIGHT π
Copyright 2024-2025 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>.
made with π by OpenSSL 3.5.0, dated 2026-09-25 β go slay your QUIC handshake, bestie π«Ά
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms