SSL_GET_SSL_CTX(3SSL)

πŸ¦‹ NAME πŸ¦‹

SSL_get_SSL_CTX β€” okay so this is literally the function that tells you which SSL_CTX birthed your SSL πŸ’– like it's giving "who's your parent" energy and honestly? iconic.


✨ SYNOPSIS ✨

#include <openssl/ssl.h>

SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl);

🌸 DESCRIPTION 🌸

bestie listen. SSL_get_SSL_CTX() hands you back a pointer to the SSL_CTX object β€” the exact one that your ssl was created from using SSL_new(3) πŸ’…

that's it. that's the whole function. she's simple, she's direct, she ate πŸ”₯


πŸŽ€ RETURN VALUES πŸŽ€

you get the pointer to the SSL_CTX object, slay πŸ’–

but BIG WARNING okay, pay attention because this is the part people mess up πŸ™ˆ:

  • this is an internal pointer β€” the reference count is not incremented. not even a little.
  • the returned pointer should not be freed 🚫 like do NOT touch it, do not free() it, do not look at it funny. it's not yours.
  • if you need to keep the SSL_CTX alive longer than the SSL object itself, you gotta call SSL_CTX_up_ref(3) to bump that reference count up yourself πŸ’… that's you doing the work. the function will not do it for you, no cap.
fr fr don't skip that SSL_CTX_up_ref(3) if you're holding on past the SSL's lifetime. that's a use-after-free waiting to happen and we are NOT about that life 😭

πŸ‘‘ SEE ALSO πŸ‘‘


Copyright 2001-2026 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, periodt πŸ’œ this was SSL_GET_SSL_CTX(3SSL) from the OpenSSL crew, version 4.0.3, dated 2026-09-29 β€” go get your SSL_CTX bestie, and remember to up_ref her if you're keeping her around πŸ«Άβœ¨πŸŽ€

πŸ“¦ where this page comes from