SSL_SET_FD(3ossl)
π 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 π
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
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms