SSL_SET_DEFAULT_STREAM_MODE(3SSL)
π SSL_SET_DEFAULT_STREAM_MODE β okay bestie, let's talk about your QUIC default stream π
So this is from the 3SSL manual, and it's all about SSL_set_default_stream_mode, plus its three lil mode constants SSL_DEFAULT_STREAM_MODE_NONE, SSL_DEFAULT_STREAM_MODE_AUTO_BIDI, and SSL_DEFAULT_STREAM_MODE_AUTO_UNI β literally the whole squad 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 π¦
okay so. A QUIC connection SSL object can have a default stream attached to it, and that's just a QUIC stream that SSL_read(3) and SSL_write(3) calls get redirected to when you call them on the QUIC connection SSL object itself. Basically, default stream handling is the vibe that lets legacy applications use QUIC kinda like they'd use a plain old traditional TLS connection. iconic of OpenSSL honestly π
When it's not disabled, a default stream gets auto-created on an outgoing connection the moment you call SSL_read(3) or SSL_write(3). No extra work, she just shows up π
Now here's the thing: a QUIC stream has to be explicitly marked as client-initiated or server-initiated up front, no takebacks. And this broadly corresponds to whether the app protocol has the client transmitting first, or the server transmitting first. So:
- if
SSL_read(3)gets called first (before any call toSSL_write(3)) after the connection is established, OpenSSL will literally just 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 wants to transmit first, creates a client-initiated stream, and binds that as the default stream β¨
By default, the default stream that gets created is bidirectional. But if you want a unidirectional stream, or if you wanna disable default stream functionality entirely, SSL_set_default_stream_mode() (more on her below) is the one that gets it done π
And when a QUIC connection SSL object has no default stream currently associated with it β say, because default stream functionality was disabled β then calls to functions that need a stream on that QUIC connection SSL object (looking at you, SSL_read(3) and SSL_write(3)) will simply fail. no stream, no service, sorry bestie π
Real talk: it is recommended that new applications, and applications that rely on multiple streams, forego the default stream functionality altogether. It's intended for legacy applications. periodt.
SSL_set_default_stream_mode() is how you configure or disable default stream handling. But listen: it can only be called on a QUIC connection SSL object prior to any default stream being created. If you're gonna use it, the move is to call it immediately after SSL_new(3), before you initiate a connection. β¨
The argument mode may be one of these options:
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. Heads up though: 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. To find out what type a stream actually is 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 behaves identically toSSL_DEFAULT_STREAM_MODE_AUTO_BIDI. And the behaviour whenSSL_read(3)is called prior to any call toSSL_write(3)? Unchanged, bestie. πSSL_DEFAULT_STREAM_MODE_NONEβ default stream creation is inhibited. full stop. And this is actually the recommended mode of operation π. With this one,SSL_read(3)andSSL_write(3)calls cannot be made on the QUIC connection SSL object directly. You must obtain streams usingSSL_new_stream(3)orSSL_accept_stream(3)in order to communicate with the peer. That's the whole assignment.
Also: 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. obviously, but they said it, so I'm saying it π
And one more thing to keep on your radar: SSL_set_incoming_stream_policy(3) interacts significantly with the default stream functionality. iykyk π
β RETURN VALUES β
SSL_set_default_stream_mode() returns 1 on success and 0 on failure. simple as that.
SSL_set_default_stream_mode() fails if it is called after a default stream has already been established. (told you β timing is everything, bestie π€)
These functions also fail if called on a QUIC stream SSL object or on a non-QUIC SSL object. Wrong object, wrong vibe. π«
π«Ά SEE ALSO π«Ά
π HISTORY π
These functions were added in OpenSSL 3.2. new-ish era, we love her β¨
π 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>.
and that's the whole page, bestie!! πβ¨π¦πΈπ«Ά
signing off from version 4.0.3, dated 2026-09-29 β this was SSL_SET_DEFAULT_STREAM_MODE(3SSL), slay, no cap, go forth and manage your streams responsibly π
π
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms