SSL_SET_CONNECT_STATE(3ossl)
πΈ SSL_SET_CONNECT_STATE π
(that's the 3ossl manual, bestie)
okay so real talk, this is THE page for telling an SSL object whether it's the client or the server in the relationship, and also for asking it which one it thinks it is. main character energy for handshakes, honestly.
β¨ NAME β¨
SSL_set_connect_state, SSL_set_accept_state, SSL_is_server β literally the functions for manipulating and examining the client or server mode of an SSL object π
π¦ 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()β sets ssl to work in client mode. slay, you're the one reaching out π«ΆSSL_set_accept_state()β sets ssl to work in server mode. you're the one being reached out to, iconic πSSL_is_server()β checks if ssl is working in server mode. a little vibe check, if you will β¨
π₯ NOTES π₯
so 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 yeah, that method might have been changed later with SSL_CTX_set_ssl_version(3) or SSL_set_ssl_method(3) β no cap.)
when you're beginning a new handshake, the SSL engine has to know whether it must call the connect (client) or accept (server) routines. even though it may be clear from the method chosen whether client or server mode was requested, the handshake routines still must be explicitly set. like, the engine is not a mind reader, bestie π
when you're using the SSL_connect(3) or SSL_accept(3) routines, the correct handshake routines are automatically set β love that for you π
ok but when performing a transparent negotiation usingSSL_write_ex(3),SSL_write(3),SSL_read_ex(3), orSSL_read(3), the handshake routines must be explicitly set in advance using eitherSSL_set_connect_state()orSSL_set_accept_state(). not optional. not automatic. do it. π
and here's the messy part β if SSL_is_server() is called before SSL_set_connect_state() or SSL_set_accept_state() is called (either automatically or explicitly), the result depends on what method was used when the SSL_CTX was created with SSL_CTX_new(3). if a generic method or a dedicated server method was passed to SSL_CTX_new(3), SSL_is_server() returns 1; otherwise, it returns 0. it's giving "it depends" and honestly that's just how it is π¦
β RETURN VALUES β
SSL_set_connect_state()andSSL_set_accept_state()do not return diagnostic information. they just do the thing, no receipts πSSL_is_server()returns1if ssl is working in server mode, or0for client mode. two moods only π
πΈ 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>.
and that's the whole page, bestie π«Ά this was 3.5.6, dated 2026-04-07 β go forth and set your connect state responsibly π
π¦ 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