SSL_CTX_SET_MODE(3)
π SSL_CTX_SET_MODE π
okay so this is a libssl / libcrypto page, section 3 of the manual, and bestie it's literally all about the ~mode~ flags β the little personality settings for your SSL engine. yes we're doing this, and yes it's gonna slay.
β¨ SYNOPSIS β¨
library βlibsslβ libcrypto #include <openssl/ssl.h>
long
SSL_CTX_set_mode(SSL_CTX *ctx, long mode);
long
SSL_set_mode(SSL *ssl, long mode);
long
SSL_CTX_clear_mode(SSL_CTX *ctx, 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 πΈ
so here's the tea: SSL_CTX_set_mode() and SSL_set_mode() turn on whatever options are hiding inside the bitmask mode β for the ctx object or the ssl object respectively. and like, options that were already enabled before you called? they stay on. no takesies-backsies, we don't disable anything here.
SSL_CTX_clear_mode() and SSL_clear_mode() are the opposite vibe: they turn off the options contained in the bitmask mode for the ctx or ssl object.
SSL_CTX_get_mode() and SSL_get_mode() just hand you back a bitmask that represents all the options currently enabled for that ctx or ssl object. it's giving "what's your status rn" and honestly? iconic.
the following options are available, and yes we're going through every single one π«Ά
SSL_MODE_ENABLE_PARTIAL_WRITEβ allowSSL_write(..., n)to returnrwith0 < r < n(i.e. report success when just a single record has been written). when this is not set β which is the default βSSL_write(3)will only report success once the complete chunk was written. onceSSL_write(3)returns withr, thenrbytes have been successfully written and the next call toSSL_write(3)must only send then β rbytes left, imitating the behaviour ofwrite(2). main character energy fr.SSL_MODE_ACCEPT_MOVING_WRITE_BUFFERβ makes it possible to retrySSL_write(3)with a changed buffer location (the buffer contents must stay the same, no cap). this is not the default because they didn't want people out here with the misconception that non-blockingSSL_write(3)behaves like non-blockingwrite(2). it does not, bestie.SSL_MODE_AUTO_RETRYβ never bother the application with retries if the transport is blocking. like, ever. so if a renegotiation takes place during normal operation, aSSL_read(3)orSSL_write(3)would return withβ1and indicate the need to retry withSSL_ERROR_WANT_READ. in a non-blocking environment, applications must be prepared to handle incomplete read/write operations. in a blocking environment, applications are not always prepared to deal with read/write operations returning without success report. the flagSSL_MODE_AUTO_RETRYwill cause read/write operations to only return after the handshake and successful completion. periodt.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 around34kper idle SSL connection π₯. heads up though: this flag has no effect on SSL v2 connections, or on DTLS connections. π
π RETURN VALUES π
SSL_CTX_set_mode(), SSL_set_mode(), SSL_CTX_clear_mode(), and SSL_clear_mode() return the new mode bitmask after adding or clearing mode.
SSL_CTX_get_mode() and SSL_get_mode() return the current bitmask. simple as that, no plot twist.
π¦ SEE ALSO π¦
ssl(3), SSL_CTX_ctrl(3), SSL_read(3), SSL_write(3)
π HISTORY π
SSL_CTX_set_mode(), SSL_set_mode(), SSL_CTX_get_mode(), and SSL_get_mode() first appeared in OpenSSL 0.9.4 and have been available since OpenBSD 2.6. absolute veterans, we stan.
SSL_CTX_clear_mode() and SSL_clear_mode() first appeared in OpenSSL 0.9.8m and have been available since OpenBSD 4.9. late bloomers but they ate.
SSL_MODE_AUTO_RETRY was added in OpenSSL 0.9.6. β
okay that's the whole page, you're officially educated π this cutie dropped on Debian, dated June 8, 2025 β go forth and set your modes, bestie π§β¨
π¦ 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) 2001, 2008 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