SSL_SET_FD(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… SSL_SET_FD β€” connect the SSL object with a file descriptor πŸ’…

okay bestie, you're in the 3ossl manual and this page is literally about hooking an SSL object up to a file descriptor. it's giving β€œnetworking but make it encrypted” energy. let's go πŸ¦‹

🌸 NAME 🌸

SSL_set_fd, SSL_set_rfd, SSL_set_wfd β€” connect the SSL object with a file descriptor. no cap, that's the whole vibe of this page πŸ’–

✨ SYNOPSIS ✨

#include <openssl/ssl.h>

int SSL_set_fd(SSL *ssl, int fd);
int SSL_set_rfd(SSL *ssl, int fd);
int SSL_set_wfd(SSL *ssl, int fd);

πŸŽ€ DESCRIPTION πŸŽ€

SSL_set_fd() sets the file descriptor fd as the input/output facility for the TLS/SSL (encrypted) side of ssl. and yeah, fd will typically be the socket file descriptor of a network connection β€” classic main character behavior πŸ”₯

when it does the thing, a socket BIO is automatically created to interface between the ssl and fd. so the BIO β€” and therefore the SSL engine β€” inherit the behaviour of fd. if fd is nonblocking, the ssl will also have nonblocking behaviour. periodt πŸ’…

when used on a QUIC connection SSL object, a datagram BIO is automatically created instead of a socket BIO. these functions fail if called on a QUIC stream SSL object β€” like, literally fail, bestie 😭

if there was already a BIO connected to ssl, BIO_free() will be called β€” for both the reading and writing side, if they're different. iconique cleanup behavior 🧚

SSL_set_rfd() and SSL_set_wfd() perform the respective action, but only for the read channel or the write channel, which can be set independently. so yes, you can split the channels, iykyk 🌸

πŸ‘‘ RETURN VALUES πŸ‘‘

the following return values can occur:

  • 0 β€” the operation failed. check the error stack to find out why. πŸ™ˆ
  • 1 β€” the operation succeeded. slay ✨

πŸ’€ NOTES πŸ’€

Windows moment, ngl πŸ™ˆ on Windows, a socket handle is a 64-bit data type (UINT_PTR), which leads to a compiler warning (conversion from 'SOCKET' to 'int', possible loss of data) when passing the socket handle to SSL_set_*fd().

for the time being, this warning can safely be ignored, because although the Microsoft documentation claims that the upper limit is INVALID_SOCKET-1 (2^64 - 2), in practice the current socket() implementation returns an index into the kernel handle table, the size of which is limited to 2^24. so yeah, it's giving β€œwarning but make it chill” πŸ’…

πŸ”₯ SEE ALSO πŸ”₯

Copyright 2000-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, bestie 🫢 this one's from OpenSSL 3.5.0, dated 2026-09-25, and it's the SSL_SET_FD(3ossl) manual. mwah πŸ’‹βœ¨

πŸ“¦ where this page comes from