SSL_SET_DEFAULT_STREAM_MODE(3ossl)
π
SSL_SET_DEFAULT_STREAM_MODE β hey bestie, welcome to the 3ossl corner of the manual π¦
okay so this whole page is about one little function and three little constants, and they're all about the β¨default streamβ¨ on a QUIC connection. it's giving "legacy app tries to pretend QUIC is just regular TLS" energy, and honestly? relatable. let's get into it π
πΈ NAME πΈ
SSL_set_default_stream_mode, SSL_DEFAULT_STREAM_MODE_NONE, SSL_DEFAULT_STREAM_MODE_AUTO_BIDI, SSL_DEFAULT_STREAM_MODE_AUTO_UNI β the whole girl gang that manages the default stream for a QUIC connection π
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
#define SSL_DEFAULT_STREAM_MODE_NONE
#define SSL_DEFAULT_STREAM_MODE_AUTO_BIDI
#define SSL_DEFAULT_STREAM_MODE_AUTO_UNI
int SSL_set_default_stream_mode(SSL *conn, uint32_t mode);
π«Ά DESCRIPTION π«Ά
so a QUIC connection SSL object may have a default stream attached to it. and what even is a default stream? bestie it's literally just a QUIC stream that SSL_read(3) and SSL_write(3) calls get redirected to when you call them on a QUIC connection SSL object. that's it. that's the whole vibe. the point of default stream handling is letting legacy applications use QUIC kinda like they'd use a traditional TLS connection β no cap π
when it's not disabled, a default stream gets automatically created on an outgoing connection the moment you call SSL_read(3) or SSL_write(3). automatic. iconic. π₯
here's the thing though β a QUIC stream has to be explicitly designated as client-initiated or server-initiated up front. like, no take-backs, decide now. this roughly corresponds to whether your application protocol has the client transmitting first or the server transmitting first. so:
- if
SSL_read(3)is called first (before any call toSSL_write(3)) after establishing a connection, OpenSSL will wait for the server to open the first server-initiated stream, and then bind that as the default stream π§ - conversely, if
SSL_write(3)is called before any call toSSL_read(3), OpenSSL assumes the client wishes to transmit first, creates a client-initiated stream, and binds that as the default stream π
by default, the default stream created is bidirectional. if you want a unidirectional stream instead, or if you wanna disable default stream functionality entirely, SSL_set_default_stream_mode() (discussed below, keep reading babe) is your girl π
β οΈ okay important: when a QUIC connectionSSLobject has no default stream currently associated with it β like, say, because default stream functionality was disabled β then calls to functions that require a stream on the QUIC connectionSSLobject (for exampleSSL_read(3)andSSL_write(3)) will straight up fail. π
and ngl, the recommendation here is: new applications, and applications that rely on multiple streams, should forego the default stream functionality altogether. it's intended for legacy applications. iykyk π¦
so SSL_set_default_stream_mode() is what configures or disables default stream handling. it can only be called on a QUIC connection SSL object prior to any default stream being created. and if you're gonna use it, the rec is to call it immediately after calling SSL_new(3), before you initiate a connection. the mode argument can be one of these three:
π the modes, ranked by vibe
SSL_DEFAULT_STREAM_MODE_AUTO_BIDIβ this is the default setting, the main character π ifSSL_write(3)is called prior to any call toSSL_read(3), a bidirectional client-initiated stream is created and bound as the default stream. ifSSL_read(3)is called prior to any call toSSL_write(3), OpenSSL waits for an incoming stream from the peer (which meansSSL_read(3)will block if the connection is in blocking mode π΄), and then binds that stream as the default stream. and listen β that incoming stream may be either bidirectional or unidirectional, so this setting does not guarantee you a bidirectional stream whenSSL_read(3)is called first. rude, i know. to figure out the type of a stream after a call toSSL_read(3), useSSL_get_stream_type(3)πSSL_DEFAULT_STREAM_MODE_AUTO_UNIβ in this mode, ifSSL_write(3)is called prior to any call toSSL_read(3), a unidirectional client-initiated stream is created and bound as the default stream. everything else is identical toSSL_DEFAULT_STREAM_MODE_AUTO_BIDI. and the behaviour whenSSL_read(3)is called prior to any call toSSL_write(3)? unchanged. same as before, bestie π¦SSL_DEFAULT_STREAM_MODE_NONEβ default stream creation is inhibited π« and this is the recommended mode of operation, periodt.SSL_read(3)andSSL_write(3)calls cannot be made on the QUIC connectionSSLobject directly. you must obtain streams usingSSL_new_stream(3)orSSL_accept_stream(3)in order to communicate with the peer. that's the assignment π
also, quick note: a default stream will not be automatically created on a QUIC connection SSL object if the default stream mode is set to SSL_DEFAULT_STREAM_MODE_NONE. consistent. we love that for us.
oh and π¨ SSL_set_incoming_stream_policy(3) interacts significantly with the default stream functionality. like, significantly significantly. keep that in mind.
π RETURN VALUES π
SSL_set_default_stream_mode()returns1on success and0on failure β¨SSL_set_default_stream_mode()fails if it's called after a default stream has already been established π (should've called it earlier, babe)- these functions fail if called on a QUIC stream
SSLobject or on a non-QUICSSLobject π
π§ SEE ALSO π§
SSL_new_stream(3), SSL_accept_stream(3), SSL_free(3), SSL_set_incoming_stream_policy(3) β go read these next, bestie, they're all in the group chat π«Ά
β HISTORY β
these functions were added in OpenSSL 3.2 π± (so if you're on something older... no they weren't, sorry bestie)
π COPYRIGHT π
Copyright 2002-2023 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>.
okay that's the whole page, you ate that π mwah. this was OpenSSL 3.5.6, dated 2026-04-07, and yes that's the SSL_SET_DEFAULT_STREAM_MODE(3ossl) manual β go slay your QUIC streams, queen πππ
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms