SSL_SET_CONNECT_STATE(3SSL)
π SSL_SET_CONNECT_STATE β okay bestie, client mode or server mode, pick ur vibe π
hi hello welcome to the OpenSSL manual page SSL_SET_CONNECT_STATE(3SSL), aka the one where u tell ur SSL object whether it's the one reaching out (client, main character energy) or the one getting reached out to (server, iconic host energy). β¨
π NAME π
SSL_set_connect_state, SSL_set_accept_state, SSL_is_server β the lil trio of functions for manipulating and examining the client-or-server mode of an SSL object. no cap, that's literally the whole job. π
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
void SSL_set_connect_state(SSL *ssl);
void SSL_set_accept_state(SSL *ssl);
int SSL_is_server(const SSL *ssl);
π¦ DESCRIPTION π¦
SSL_set_connect_state()β setssslto work in client mode. ur baby is the one dialing out. πSSL_set_accept_state()β setssslto work in server mode. ur baby is the one picking up. π«ΆSSL_is_server()β checks ifsslis working in server mode. it's a vibe check. one question only: are u the server or not. π
β¨ NOTES β¨
okay so context first: when the SSL_CTX object was created with SSL_CTX_new(3), it got assigned either a dedicated client method, a dedicated server method, or a generic method that can be used for both client and server connections. (and pssst β that method might have been changed later with SSL_CTX_set_ssl_version(3) or SSL_set_ssl_method(3), so don't just assume it's the same as birth.) πΌ
When u begin a new handshake, the SSL engine must know whether it should call the connect (client) routines or the accept (server) routines. and here's the thing: even though it might be totally obvious from the method u chose whether client or server mode was requested... the handshake routines must still be explicitly set. the engine does not read minds. it's giving "i need it in writing, bestie." π
Now the part that saves u effort, depending on what ur doing:
- If ur using
SSL_connect(3)orSSL_accept(3), the correct handshake routines are automatically set for u. slay, no extra steps. π - If ur doing a transparent negotiation using
SSL_write_ex(3),SSL_write(3),SSL_read_ex(3), orSSL_read(3), then the handshake routines must be explicitly set in advance using eitherSSL_set_connect_state()orSSL_set_accept_state(). do it urself, no autopilot here. π
And the sneaky one β the edge case that will absolutely humble u:
IfSSL_is_server()is called beforeSSL_set_connect_state()orSSL_set_accept_state()is called (whether automatically or explicitly), the result depends on what method was used whenSSL_CTXwas created withSSL_CTX_new(3).
so like β what does it depend on, exactly? π
- If a generic method or a dedicated server method was passed to
SSL_CTX_new(3),SSL_is_server()returns1. - Otherwise, it returns
0.
periodt. that's the whole rule. π
π RETURN VALUES π
SSL_set_connect_state()andSSL_set_accept_state()do not return diagnostic information. they just do the thing and dip. no receipt, no error message, nothing. πSSL_is_server()returns1ifsslis working in server mode, or0for client mode.
π SEE ALSO π
ssl(7)SSL_new(3)SSL_CTX_new(3)SSL_connect(3)SSL_accept(3)SSL_write_ex(3)SSL_write(3)SSL_read_ex(3)SSL_read(3)SSL_do_handshake(3)SSL_CTX_set_ssl_version(3)
π COPYRIGHT π
Copyright 2001-2017 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, u ate it up fr fr π this was OpenSSL version 4.0.3, dated 2026-09-29 β mwah, go set ur connect state and be the client of ur dreams, bestie π
ππ§
π¦ where this page comes from
- ubuntu stonking: libssl-doc 4.0.3-1ubuntu1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms