SSL_GET_STREAM_ID(3SSL)

πŸ’… SSL_GET_STREAM_ID β€” the OpenSSL one, section 3SSL

okay bestie so this is SSL_GET_STREAM_ID(3SSL) from the OpenSSL manual, and it's literally all about peeking at QUIC stream IDs and figuring out what kind of stream you're holding πŸ¦‹


✨ NAME ✨

SSL_get_stream_id, SSL_get_stream_type, SSL_STREAM_TYPE_NONE, SSL_STREAM_TYPE_READ, SSL_STREAM_TYPE_WRITE, SSL_STREAM_TYPE_BIDI, SSL_is_stream_local β€” get QUIC stream ID and stream type information. that's the whole vibe πŸ’–


🌸 SYNOPSIS 🌸

#include <openssl/ssl.h>

uint64_t SSL_get_stream_id(SSL *ssl);

#define SSL_STREAM_TYPE_NONE
#define SSL_STREAM_TYPE_BIDI
#define SSL_STREAM_TYPE_READ
#define SSL_STREAM_TYPE_WRITE
int SSL_get_stream_type(SSL *ssl);

int SSL_is_stream_local(SSL *ssl);

πŸ‘‘ DESCRIPTION πŸ‘‘

okay so buckle up, there are three functions and a whole little family of constants here πŸŽ€

SSL_get_stream_id() hands you the QUIC stream ID for a QUIC stream SSL object. and like, it ALSO works if you pass it a QUIC connection SSL object that has a default stream attached. cute right? πŸ’œ

SSL_get_stream_type() is the one that tells you what you can actually do with this stream. it returns exactly one of these bad boys:

  • SSL_STREAM_TYPE_NONE β€” bestie the SSL object is a QUIC connection SSL object with no default stream attached. that's it. nothing to see here πŸ’€
  • SSL_STREAM_TYPE_BIDI β€” the SSL object is either a non-QUIC SSL object, OR it's a QUIC stream object (or a QUIC connection SSL object with a default stream attached), and that stream is a bidirectional QUIC stream. both directions, main character energy πŸ”₯
  • SSL_STREAM_TYPE_READ β€” the SSL object is a QUIC stream object (or a QUIC connection SSL object with a default stream attached), and that stream is a unidirectional QUIC stream that was initiated by the remote peer. so like... you can read from it, but you cannot write to it. read-only era πŸ™ˆ
  • SSL_STREAM_TYPE_WRITE β€” the SSL object is a QUIC stream object (or a QUIC connection SSL object with a default stream attached), and that stream is a unidirectional QUIC stream that was initiated by the local application. so you can write to it, but you cannot read from it. write-only era ✨

and SSL_is_stream_local()? it tells you whether a stream was locally created. simple as that 🫢


πŸ“ NOTES πŸ“

lowkey important stuff incoming, pay attention bestie 😭

so QUICv1 does assign specific meaning to the low two bits of a QUIC stream ID. BUT β€” and this is the tea β€” QUIC stream IDs in future versions of QUIC are not required to have the same semantics. so do NOT determine stream properties using these bits. no cap. instead, use SSL_get_stream_type() to determine the stream type, and SSL_get_stream_is_local() to determine the stream initiator πŸ‘‘

also, SSL_get_stream_type() identifies the type of a QUIC stream based on its identity, and it does not indicate whether an operation can currently be successfully performed on a stream. for example: you might locally initiate a unidirectional stream, write to it, and then conclude the stream using SSL_stream_conclude(3), meaning that it can no longer be written to β€” but SSL_get_stream_type() would still return SSL_STREAM_TYPE_WRITE. it's giving "the label is forever" πŸ’… the value returned by SSL_get_stream_type() does not vary over the lifespan of a stream.


🌈 RETURN VALUES 🌈

  • SSL_get_stream_id() returns a QUIC stream ID, or UINT64_MAX if you call it on an SSL object which is not a QUIC SSL object, or if you call it on a QUIC connection SSL object without a default stream attached. quick side note: valid QUIC stream IDs are always below 2**62. ⭐
  • SSL_get_stream_type() returns one of the SSL_STREAM_TYPE values. that's the whole menu πŸ’–
  • SSL_is_stream_local() returns 1 if you call it on a QUIC stream SSL object which represents a stream which was locally initiated. it returns 0 if you call it on a QUIC stream SSL object which represents a stream which was remotely initiated by a peer, and -1 if you call it on any other kind of SSL object. three possible answers, no in-between πŸ¦‹

πŸ’œ SEE ALSO πŸ’œ


πŸŽ€ HISTORY πŸŽ€

these functions were added in OpenSSL 3.2. new-ish, but iconic ✨


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>.

fr fr read the license bestie, it's not optional and it's not a vibe check you want to fail πŸ’€

and that's the page!! this was OpenSSL 4.0.3, dated 2026-09-29, and it's the SSL_GET_STREAM_ID(3SSL) manual. slay, go read your QUIC streams responsibly πŸ‘‘πŸ’–

πŸ“¦ where this page comes from