SSL_CTX_USE_SERVERINFO(3SSL)

πŸ’– SSL_CTX_USE_SERVERINFO β€” use serverinfo extension πŸ’–

okay bestie, so this is the OpenSSL manpage for three lil functions that all do the same iconic thing: SSL_CTX_use_serverinfo_ex, SSL_CTX_use_serverinfo, and SSL_CTX_use_serverinfo_file. they use the serverinfo extension. that's the name of the game. we're in the 3SSL manual section, and yes, we're gonna go through every single byte of it together. no skimming, no skipping, that's the rule 🫢


✨ SYNOPSIS ✨

like, here's literally how you call them:

#include <openssl/ssl.h>

int SSL_CTX_use_serverinfo_ex(SSL_CTX *ctx, unsigned int version,
                              const unsigned char *serverinfo,
                              size_t serverinfo_length);

int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo,
                           size_t serverinfo_length);

int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file);

🌸 DESCRIPTION 🌸

So. These functions load "serverinfo" TLS extensions into the SSL_CTX. And a "serverinfo" extension, for the record, is returned in response to an empty ClientHello Extension. that's the whole vibe check of it. it's giving "you sent me an empty vibe, I send you back an extension." πŸ’…

the _ex one? the main character tbh

SSL_CTX_use_serverinfo_ex() loads one or more serverinfo extensions from a byte array into ctx. The version parameter specifies the format of the byte array provided in *serverinfo which is of length serverinfo_length. okay so version is deciding how we're reading this array. important.

If version is SSL_SERVERINFOV2 then the extensions in the array must consist of:

  • a 4-byte context
  • a 2-byte Extension Type
  • a 2-byte length
  • and then length bytes of extension_data

The context and type values have the same meaning as for SSL_CTX_add_custom_ext(3). and lowkey here's a detail you do NOT wanna miss: if serverinfo is being loaded for extensions to be added to a Certificate message, then the extension will only be added for the first certificate in the message β€” which is always the end-entity certificate. so just the one. the end-entity one. periodt.

If version is SSL_SERVERINFOV1 then the extensions in the array must consist of:

  • a 2-byte Extension Type
  • a 2-byte length
  • and then length bytes of extension_data

The type value has the same meaning as for SSL_CTX_add_custom_ext(3). And in this case, the following default context value will be used:

SSL_EXT_TLS1_2_AND_BELOW_ONLY | SSL_EXT_CLIENT_HELLO
| SSL_EXT_TLS1_2_SERVER_HELLO | SSL_EXT_IGNORE_ON_RESUMPTION

that's your shortcut context, you don't gotta spell it out yourself πŸ’œ

the plain one

SSL_CTX_use_serverinfo() does the same thing as SSL_CTX_use_serverinfo_ex() except that there is no version parameter β€” so a default version of SSL_SERVERINFOV1 is used instead. it's the chill version. no version drama.

the file one

SSL_CTX_use_serverinfo_file() loads one or more serverinfo extensions from file into ctx. The extensions must be in PEM format. Each extension must be in a format as described above for SSL_CTX_use_serverinfo_ex(). and β€” listen β€” each PEM extension name must begin with the phrase "BEGIN SERVERINFOV2 FOR " for SSL_SERVERINFOV2 data or "BEGIN SERVERINFO FOR " for SSL_SERVERINFOV1 data. yes the space at the end of those phrases matters, she's specific like that πŸŽ€

the certificate situation (read this one bestie)

If more than one certificate (RSA/DSA) is installed using SSL_CTX_use_certificate(), the serverinfo extension will be loaded into the last certificate installed. If e.g. the last item was an RSA certificate, the loaded serverinfo extension data will be loaded for that certificate. To use the serverinfo extension for multiple certificates, SSL_CTX_use_serverinfo() needs to be called multiple times, once after each time a certificate is loaded via a call to SSL_CTX_use_certificate().

okay so this is the trap: last one wins. it's not a "blast it across all of them" situation. one cert, one call, in order. iykyk πŸ”₯

⭐ RETURN VALUES ⭐

On success, the functions return 1. On failure, the functions return 0. Check out the error stack to find out the reason β€” like, go read the receipts, she left them for you. 🌈


πŸ¦‹ SEE ALSO πŸ¦‹


Copyright 2013-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, every byte accounted for πŸ’– this was version 4.0.3, dated 2026-09-29, from the SSL_CTX_USE_SERVERINFO(3SSL) manual. go forth and load those extensions, you absolute icon πŸŽ€βœ¨

πŸ“¦ where this page comes from