SSL_SESSION_GET0_HOSTNAME(3ossl)
π SSL_SESSION_GET0_HOSTNAME(3ossl)
okay so bestie, this is the 3ossl manual page for SSL_SESSION_get0_hostname, SSL_SESSION_set1_hostname, SSL_SESSION_get0_alpn_selected, and SSL_SESSION_set1_alpn_selected β literally the getters and setters for the SNI and ALPN data chillin' inside a session. it's giving "session metadata management" and honestly? we're obsessed. π
β¨ NAME β¨
SSL_SESSION_get0_hostname, SSL_SESSION_set1_hostname, SSL_SESSION_get0_alpn_selected, SSL_SESSION_set1_alpn_selected β get and set SNI and ALPN data associated with a session π¦
πΈ SYNOPSIS πΈ
#include <openssl/ssl.h>
const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);
int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);
void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,
const unsigned char **alpn,
size_t *len);
int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, const unsigned char *alpn,
size_t len);
like, copy-paste energy but make it β¨cryptographicβ¨
π DESCRIPTION π
π the hostname girlies (SNI)
SSL_SESSION_get0_hostname() retrieves the SNI value that was sent by the client when the session was created β but only if it was accepted by the server. otherwise it's a big fat NULL, no cap. π
β οΈ the value returned is a pointer to memory maintained within s, and it should not be free'd. that memory is not yours, bestie β hands off. π
SSL_SESSION_set1_hostname() sets the SNI value for the hostname to a copy of the string you hand it in hostname. so like, it clones it. very demure, very mindful. π§
π the ALPN girlies
SSL_SESSION_get0_alpn_selected() retrieves the selected ALPN protocol for this session, plus its associated length in bytes. the returned value of *alpn is, again, a pointer to memory maintained within s and should not be free'd. same rules, same vibe check. π
SSL_SESSION_set1_alpn_selected() sets the ALPN protocol for this session to the value in alpn, which should be of length len bytes. a copy of the input value is made, and the caller retains ownership of the memory pointed to by alpn. so you keep your stuff, it keeps its stuff. iconic mutual respect. π«Ά
π₯ RETURN VALUES π₯
SSL_SESSION_get0_hostname()β returns either a string orNULL, based on whether there is the SNI value sent by client. it's giving "will she or won't she." πSSL_SESSION_set1_hostname()β returns1on success or0on error.SSL_SESSION_set1_alpn_selected()β returns1on success or0on error.
π tiny note:SSL_SESSION_get0_alpn_selected()isn't listed here β it returnsvoid, so there's nothing to check. it just vibes and fills in your pointers.
π SEE ALSO π
ssl(7), d2i_SSL_SESSION(3), SSL_SESSION_get_time(3), SSL_SESSION_free(3) β go read these next, iykyk π
π HISTORY π
the SSL_SESSION_set1_hostname(), SSL_SESSION_get0_alpn_selected() and SSL_SESSION_set1_alpn_selected() functions were added in OpenSSL 1.1.1. so they're not new new, but they're still slaying. β¨
π COPYRIGHT π
Copyright 2016-2025 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 little gem lives in OpenSSL 3.5.0 and was dated 2026-09-25, filed under the manual name SSL_SESSION_GET0_HOSTNAME(3ossl) in case you ever need to find it again. mwah π periodt. πβ
π¦ where this page comes from
- opensuse-leap 16.0: openssl-3-doc 3.5.0-160000.11.1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms