SSL_CTX_USE_SERVERINFO(3ossl)

πŸ“¦
version 15.1 Β· 3 versions
, in freebsd 15.1

πŸ’… SSL_CTX_USE_SERVERINFO πŸ’…

okay so this is a page from the OpenSSL manual, section 3ossl, and bestie it's literally all about the serverinfo extension. buckle up, it's giving niche-but-iconic πŸŽ€


✨ NAME ✨

SSL_CTX_use_serverinfo_ex, SSL_CTX_use_serverinfo, SSL_CTX_use_serverinfo_file β€” the trio that lets you use the serverinfo extension πŸ¦‹


✨ SYNOPSIS ✨

#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);

like, three whole functions, one header, we love a package deal 🫢


✨ DESCRIPTION ✨

So these functions load "serverinfo" TLS extensions into the SSL_CTX. And what even is a "serverinfo" extension? It's the thing that gets returned in response to an empty ClientHello Extension. periodt. πŸ’…

🧚 SSL_CTX_use_serverinfo_ex()

This one 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.

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 real talk: 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). iykyk.

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 the following default context value will be used in this case:

SSL_EXT_TLS1_2_AND_BELOW_ONLY | SSL_EXT_CLIENT_HELLO
| SSL_EXT_TLS1_2_SERVER_HELLO | SSL_EXT_IGNORE_ON_RESUMPTION

no cap, that's the whole default vibe check right there ✨

🧚 SSL_CTX_use_serverinfo()

This 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 low-effort version and honestly? valid. πŸ’œ

🧚 SSL_CTX_use_serverinfo_file()

This one 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(). Each PEM extension name must begin with the phrase "BEGIN SERVERINFOV2 FOR " for SSL_SERVERINFOV2 data or "BEGIN SERVERINFO FOR " for SSL_SERVERINFOV1 data. πŸ‘‘

⚠️ okay important one, bestie, listen up: 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. So like, 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(). don't @ me, that's just how it is 😭

✨ RETURN VALUES ✨

  • On success, the functions return 1. πŸŽ‰ slay!
  • On failure, the functions return 0. πŸ’€

Check out the error stack to find out the reason β€” that's where the lore lives.


✨ SEE ALSO ✨

the one and only reference, we stan a minimal bibliography 🌸


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!! 🫢 this was 3.5.6, dated 2026-04-07, and it's the SSL_CTX_USE_SERVERINFO(3ossl) page β€” go forth and configure your extensions, main character 🌈⭐

πŸ“¦ where this page comes from