D2I_SSL_SESSION(3ossl)

πŸ“¦ version 3.5.0, in opensuse-leap 16.0

πŸ’… D2I_SSL_SESSION

okay so bestie, welcome to the 3ossl manual page for D2I_SSL_SESSION β€” yes that's the actual manual name, it's giving very "my full legal name is on the birth certificate" energy πŸŽ€ this is the little trio of functions that turn an SSL_SESSION object into its ASN1 representation and back again, and honestly? iconic. let's get into it ✨


✨ NAME ✨

d2i_SSL_SESSION, d2i_SSL_SESSION_ex, i2d_SSL_SESSION β€” these three convert an SSL_SESSION object from and to its ASN1 representation πŸ¦‹


🌸 SYNOPSIS 🌸

#include <openssl/ssl.h>

SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp,
                             long length);
SSL_SESSION *d2i_SSL_SESSION_ex(SSL_SESSION **a, const unsigned char **pp,
                                long length, OSSL_LIB_CTX *libctx,
                                const char *propq);
int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp);

like, just look at them. three little functions. all business πŸ’…


πŸ’– DESCRIPTION πŸ’–

so these functions decode and encode an SSL_SESSION object, periodt. for the encoding details you're gonna wanna go peek at d2i_X509(3) β€” that's where the real ASN1 lore lives πŸ”₯

now here's the part where we get a little serious, because this one actually matters:

SSL_SESSION objects keep internal link information about the session cache list, when being inserted into one SSL_CTX object's session cache. one SSL_SESSION object, regardless of its reference count, must therefore only be used with one SSL_CTX object (and the SSL objects created from this SSL_CTX object). no sharing, no mixing, no "but it's just one little session" 😭

so yeah β€” one session object, one SSL_CTX, and the SSL objects that came from that SSL_CTX. that's the vibe check and it does not negotiate πŸ™ˆ


⭐ RETURN VALUES ⭐

  • d2i_SSL_SESSION() and d2i_SSL_SESSION_ex() β€” they return a pointer to the newly allocated SSL_SESSION object πŸŽ€ if it fails, you get the NULL-pointer back, and you can grab the error message from the error stack. classic. check your stack bestie πŸ‘‘
  • i2d_SSL_SESSION() β€” returns the size of the ASN1 representation in bytes ✨ but when the session is not valid, 0 is returned and no operation is performed. like she simply will not do it. and honestly, respect πŸ’…

πŸ¦‹ SEE ALSO πŸ¦‹

go read them, iykyk πŸ“šπŸ’œ


🌈 HISTORY 🌈

the function d2i_SSL_SESSION_ex() was added in OpenSSL 3.2 β€” so she's the new girl and she ate 🫢✨


Copyright 2001-2024 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 πŸ“ mwah πŸ’‹ β€” this was version 3.5.0, dated 2026-09-25, coming at you from the 3ossl manual, and she slayed the entire time πŸ’–βœ¨πŸ§š

πŸ“¦ where this page comes from