SSL_CTX_SET_MODE(3ossl)
π SSL_CTX_SET_MODE β OpenSSL, bestie edition π
okay so this is the 3ossl manual page, and it's literally all about manipulating the SSL engine mode β like, flipping the little switches that change how your TLS connection behaves. no cap, these functions are the ones you call when you want to whisper to the engine "heyβ¦ do it this way" π¦
β¨ SYNOPSIS β¨
#include <openssl/ssl.h>
long SSL_CTX_set_mode(SSL_CTX *ctx, long mode);
long SSL_CTX_clear_mode(SSL_CTX *ctx, long mode);
long SSL_set_mode(SSL *ssl, long mode);
long SSL_clear_mode(SSL *ssl, long mode);
long SSL_CTX_get_mode(SSL_CTX *ctx);
long SSL_get_mode(SSL *ssl);
πΈ DESCRIPTION πΈ
SSL_CTX_set_mode() adds the mode set via bit-mask in mode to ctx. Options already set before are not cleared β it's additive, she's stacking, periodt. SSL_CTX_clear_mode() removes the mode set via bit-mask in mode from ctx.
SSL_set_mode() adds the mode set via bit-mask in mode to ssl. Options already set before are not cleared. SSL_clear_mode() removes the mode set via bit-mask in mode from ssl.
SSL_CTX_get_mode() returns the mode set for ctx.
SSL_get_mode() returns the mode set for ssl.
π«Ά NOTES π«Ά
here's the menu of mode changes you can flip on, bestie β the way that each one is a whole personality trait for your connection π
SSL_MODE_ENABLE_PARTIAL_WRITEβ AllowSSL_write_ex(..., n, &r)to return with0 < r < n(i.e. report success when just a single record has been written). This works in a similar way forSSL_write(). When not set (the default),SSL_write_ex()orSSL_write()will only report success once the complete chunk was written. OnceSSL_write_ex()orSSL_write()returns successful, r bytes have been written and the next call toSSL_write_ex()orSSL_write()must only send the n-r bytes left, imitating the behaviour ofwrite().
π¨ This mode cannot be enabled while in the middle of an incomplete write operation. like, she said no interruptions.
SSL_MODE_ACCEPT_MOVING_WRITE_BUFFERβ Make it possible to retrySSL_write_ex()orSSL_write()with changed buffer location (the buffer contents must stay the same). This is not the default to avoid the misconception that nonblockingSSL_write()behaves like nonblockingwrite(). πSSL_MODE_AUTO_RETRYβ During normal operations, non-application data records might need to be sent or received that the application is not aware of. If a non-application data record was processed,SSL_read_ex(3)andSSL_read(3)can return with a failure and indicate the need to retry withSSL_ERROR_WANT_READ. If such a non-application data record was processed, the flagSSL_MODE_AUTO_RETRYcauses it to try to process the next record instead of returning.
In a nonblocking environment applications must be prepared to handle incomplete read/write operations. Setting SSL_MODE_AUTO_RETRY for a nonblocking BIO will process non-application data records until either no more data is available or an application data record has been processed.
In a blocking environment, applications are not always prepared to deal with the functions returning intermediate reports such as retry requests, and setting the SSL_MODE_AUTO_RETRY flag will cause the functions to only return after successfully processing an application data record or a failure.
Turning off SSL_MODE_AUTO_RETRY can be useful with blocking BIOs in case they are used in combination with something like select() or poll(). Otherwise the call to SSL_read() or SSL_read_ex() might hang when a non-application record was sent and no application data was sent. π
SSL_MODE_RELEASE_BUFFERSβ When we no longer need a read buffer or a write buffer for a given SSL, then release the memory we were using to hold it. Using this flag can save around 34k per idle SSL connection β that's a glow-up for your RAM, honestly. This flag has no effect on SSL v2 connections, or on DTLS connections.SSL_MODE_SEND_FALLBACK_SCSVβ SendTLS_FALLBACK_SCSVin the ClientHello. To be set only by applications that reconnect with a downgraded protocol version; seedraft-ietf-tls-downgrade-scsv-00for details.
DO NOT ENABLE THIS if your application attempts a normal handshake. Only use this in explicit fallback retries, following the guidance in draft-ietf-tls-downgrade-scsv-00. like seriously bestie, read the draft, don't just vibe. π
SSL_MODE_ASYNCβ Enable asynchronous processing. TLS I/O operations may indicate a retry withSSL_ERROR_WANT_ASYNCwith this mode set if an asynchronous capable engine is used to perform cryptographic operations. SeeSSL_get_error(3).SSL_MODE_DTLS_SCTP_LABEL_LENGTH_BUGβ Older versions of OpenSSL had a bug in the computation of the label length used for computing the endpoint-pair shared secret. The bug was that the terminating zero was included in the length of the label. Setting this option enables this behaviour to allow interoperability with such broken implementations. Please note that setting this option breaks interoperability with correct implementations. This option only applies to DTLS over SCTP. it's giving "compatibility with the messy ex" energy π
All modes are off by default except for SSL_MODE_AUTO_RETRY which is on by default since 1.1.1. β
π RETURN VALUES π
SSL_CTX_set_mode() and SSL_set_mode() return the new mode bit-mask after adding mode.
SSL_CTX_get_mode() and SSL_get_mode() return the current bit-mask.
π¦ SEE ALSO π¦
ssl(7), SSL_read_ex(3), SSL_read(3), SSL_write_ex(3) or SSL_write(3), SSL_get_error(3)
π HISTORY π
SSL_MODE_ASYNC was added in OpenSSL 1.1.0. β¨
π COPYRIGHT π
Copyright 2001-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 version slipped out under 3.5.6, dated 2026-04-07 β go forth and flip those mode bits responsibly, mwah ππ§
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms