SSL_SET_FD(3)
π SSL_SET_FD β bestie, let's hook your SSL object up to a file descriptor
okay so this one's from libssl and libcrypto, and you get to it like this:
#include <openssl/ssl.h>
That's the whole invite to the party, no cap. β¨
πΈ SYNOPSIS πΈ
int
SSL_set_fd(SSL *ssl, int fd);
int
SSL_set_rfd(SSL *ssl, int fd);
int
SSL_set_wfd(SSL *ssl, int fd);
three little functions, all taking an SSL *ssl and an int fd, all handing you back an int. iconic trio fr fr.
π¦ DESCRIPTION π¦
So SSL_set_fd() sets the file descriptor fd as the input/output facility for the TLS/SSL (encrypted) side of ssl. And fd will typically be the socket file descriptor of a network connection β like, that's the main character use case, iykyk. π₯
When it's doing the operation, a socket BIO is automatically created to interface between the ssl and the fd. bestie it just happens, you don't have to do it yourself π
And the BIO β and therefore the SSL engine β inherits the behaviour of fd. So if fd is non-blocking, the ssl will also have non-blocking behaviour. the vibes propagate. no take-backsies.
Also important: if there was already a BIO connected to ssl, then BIO_free(3) will be called β for both the reading and writing side, if they're different. so the old one gets politely yeeted π«Ά
Then SSL_set_rfd() and SSL_set_wfd() do the respective action, but only for the read channel or the write channel, which can be set independently. so if you only wanna commit on one side of the relationship, that's your moment π
β RETURN VALUES β
These are the possible return values, keep 'em in mind:
0β the operation failed. π Check the error stack to find out why (the error stack is literally the receipts).1β the operation succeeded. slay! π
π SEE ALSO π
go read those too, they're all part of the same friend group π
π HISTORY π
SSL_set_fd() appeared in SSLeay 0.4 or earlier β like, ancient. SSL_set_rfd() and SSL_set_wfd() first appeared in SSLeay 0.6.0. And these functions have been available since OpenBSD 2.4. elders of the group chat, honestly π
ngl this one's short and sweet, so go set some fds and be free π¦
okay that's the whole page!! this came from the Debian build, dated June 8, 2025, and you can find it filed under the SSL_SET_FD(3) section of the Library Functions Manual. mwah πβ¨π
π¦ where this page comes from
- alpine 3.24: libressl-doc 4.3.1-r0 Β· custom
- arch rolling: libressl 4.4.0-1 Β· ISC AND custom:OpenSSL
- Copyright (c) 2000, 2013 The OpenSSL Project. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms