SSL_SET_DEFAULT_STREAM_MODE(3ossl)

πŸ’– SSL_SET_DEFAULT_STREAM_MODE πŸ’–

okay bestie, welcome to SSL_SET_DEFAULT_STREAM_MODE(3ossl), an OpenSSL manual page, no cap. this one's all about managing the default stream for a QUIC connection and honestly? it's giving "legacy app glow-up." 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 little 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 πŸ‘‘

so. a QUIC connection SSL object can have a default stream attached to it. what even is a default stream? it's a QUIC stream where all your SSL_read(3) and SSL_write(3) calls get redirected when you make them on a QUIC connection SSL object. that's it, that's the vibe. default stream handling is literally the thing that lets legacy applications use QUIC kinda like they'd use a traditional TLS connection. slay for backwards compat 🫢

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). auto-magic ✨

here's the tea tho: a QUIC stream has to be explicitly designated as client-initiated or server-initiated up front, periodt. this roughly maps to whether your application protocol has the client transmitting first, or the server transmitting first. so check it:

  • if SSL_read(3) is called first (before any call to SSL_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. patient queen energy.
  • conversely, if SSL_write(3) is called before any call to SSL_read(3), OpenSSL assumes the client wants to transmit first, creates a client-initiated stream, and binds that as the default stream. main character behavior, honestly.

by default, the default stream that gets created is bidirectional. if you want a unidirectional stream instead, or if you wanna disable default stream functionality entirely, SSL_set_default_stream_mode() (more on that below, keep reading πŸ’–) is how you do it.

now, when a QUIC connection SSL object has no default stream currently associated with it β€” like, say, because default stream functionality was disabled β€” calls to functions that require a stream on the QUIC connection SSL object (for example, SSL_read(3) and SSL_write(3)) will fail. not a vibe. πŸ’€

real talk: it is recommended that new applications, and applications that rely on multiple streams, forego use of the default stream functionality β€” because it's intended for legacy applications. iykyk.

SSL_set_default_stream_mode() is the function that configures or disables default stream handling. 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 recommendation is to call it immediately after calling SSL_new(3), before you initiate a connection. ⭐

the argument mode may be one of the following options, bestie:

  • SSL_DEFAULT_STREAM_MODE_AUTO_BIDI β€” this is the default setting. if SSL_write(3) is called prior to any call to SSL_read(3), a bidirectional client-initiated stream is created and bound as the default stream. if SSL_read(3) is called prior to any call to SSL_write(3), OpenSSL waits for an incoming stream from the peer (which means SSL_read(3) will block if the connection is in blocking mode 😭), and then binds that stream as the default stream. note that this incoming stream may be either bidirectional or unidirectional β€” so this setting does not guarantee you'll have a bidirectional stream when SSL_read(3) is called first. to figure out the type of a stream after a call to SSL_read(3), use SSL_get_stream_type(3). πŸ’…
  • SSL_DEFAULT_STREAM_MODE_AUTO_UNI β€” in this mode, if SSL_write(3) is called prior to any call to SSL_read(3), a unidirectional client-initiated stream is created and bound as the default stream. behaviour is otherwise identical to SSL_DEFAULT_STREAM_MODE_AUTO_BIDI. and the behaviour when SSL_read(3) is called prior to any call to SSL_write(3) is unchanged. same as it ever was πŸŽ€
  • SSL_DEFAULT_STREAM_MODE_NONE β€” default stream creation is inhibited. this is the recommended mode of operation. SSL_read(3) and SSL_write(3) calls cannot be made on the QUIC connection SSL object directly. you must obtain streams using SSL_new_stream(3) or SSL_accept_stream(3) in order to communicate with the peer. no shortcuts, bestie, do it properly πŸ”₯

also important: 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.

and heads up β€” SSL_set_incoming_stream_policy(3) interacts significantly with the default stream functionality. they're in the group chat together, they talk. 🧚


🌈 RETURN VALUES 🌈

  • SSL_set_default_stream_mode() returns 1 on success and 0 on failure. iconic binary moment.
  • SSL_set_default_stream_mode() fails if it is called after a default stream has already been established. too late, girl πŸ’€
  • these functions fail if called on a QUIC stream SSL object or on a non-QUIC SSL object. wrong object, wrong vibe, hard no. πŸ™ˆ

πŸ’œ SEE ALSO πŸ’œ

SSL_new_stream(3), SSL_accept_stream(3), SSL_free(3), SSL_set_incoming_stream_policy(3)

go read those too, bestie, they're all connected πŸ¦‹


πŸ“œ HISTORY πŸ“œ

these functions were added in OpenSSL 3.2. not ancient lore, we're talking recent-ish ✨


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 πŸ’– this was OpenSSL 3.5.9, dated 2026-09-29 β€” stay hydrated, read your return values, and remember: always check if your default stream already exists before you set the mode. mwah πŸ’…πŸŒΈπŸ«Ά

πŸ“¦ where this page comes from