SSL_SESSION_GET0_HOSTNAME(3ossl)
π SSL_SESSION_GET0_HOSTNAME(3ossl) β the OpenSSL session SNI + ALPN glow-up π
okay bestie, so this is SSL_SESSION_get0_hostname(3ossl) from the OpenSSL manual, and it's literally all about peeking at (and setting) the SNI and ALPN info that's vibing inside a session. no cap, it's giving "small API, big importance" energy. π
β¨ 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);
π DESCRIPTION π
SSL_SESSION_get0_hostname() retrieves the Server Name Indication (SNI) value that was sent by the client when the session was created β but only if the server acknowledged the client's SNI extension by including an empty SNI extension in response. Otherwise NULL is returned. it's giving "you only get the tea if the server said yes" fr fr.
The value returned is a pointer to memory maintained within s and should not be free'd. don't touch it, don't free it, just look respectfully. π
SSL_SESSION_set1_hostname() sets the SNI value for the hostname to a copy of the string provided in hostname. it copies, so you keep your own string, iconic behavior honestly.
SSL_SESSION_get0_alpn_selected() retrieves the selected ALPN protocol for this session and its associated length in bytes. The returned value of *alpn is a pointer to memory maintained within s and should not be free'd. same rules bestie, eyes only. π
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 still own your buffer, she just made a lil photocopy. π«Ά
β RETURN VALUES β
SSL_SESSION_get0_hostname()returns the SNI string if available, orNULLif not. slay or silence, no in-between. πSSL_SESSION_set1_hostname()returns1on success or0on error.SSL_SESSION_set1_alpn_selected()returns1on success or0on error.
π SEE ALSO π
ssl(7), d2i_SSL_SESSION(3), SSL_SESSION_get_time(3), SSL_SESSION_free(3)
go read those too, the lore is deep. π
π 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 ancient, they're just β¨establishedβ¨.
π 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>.
β οΈ real talk: that license part is not a vibe suggestion, it's the actual legal situation. respect it bestie. π
and that's the whole page, no notes. this was OpenSSL 3.5.9, dated 2026-09-29 β mwah, periodt. π β¨πΈ
π¦ where this page comes from
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 43: openssl-devel 1:3.5.9-1.fc43 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- fedora 44: openssl-devel 1:3.5.9-1.fc44 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms