1e71b7053SJung-uk Kim=pod 2e71b7053SJung-uk Kim 3e71b7053SJung-uk Kim=head1 NAME 4e71b7053SJung-uk Kim 5e71b7053SJung-uk KimSSL_SESSION_get0_hostname, 6e71b7053SJung-uk KimSSL_SESSION_set1_hostname, 7e71b7053SJung-uk KimSSL_SESSION_get0_alpn_selected, 8e71b7053SJung-uk KimSSL_SESSION_set1_alpn_selected 9da327cd2SJung-uk Kim- get and set SNI and ALPN data associated with a session 10e71b7053SJung-uk Kim 11e71b7053SJung-uk Kim=head1 SYNOPSIS 12e71b7053SJung-uk Kim 13e71b7053SJung-uk Kim #include <openssl/ssl.h> 14e71b7053SJung-uk Kim 15e71b7053SJung-uk Kim const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s); 16e71b7053SJung-uk Kim int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname); 17e71b7053SJung-uk Kim 18e71b7053SJung-uk Kim void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s, 19e71b7053SJung-uk Kim const unsigned char **alpn, 20e71b7053SJung-uk Kim size_t *len); 21e71b7053SJung-uk Kim int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, const unsigned char *alpn, 22e71b7053SJung-uk Kim size_t len); 23e71b7053SJung-uk Kim 24e71b7053SJung-uk Kim=head1 DESCRIPTION 25e71b7053SJung-uk Kim 26e71b7053SJung-uk KimSSL_SESSION_get0_hostname() retrieves the SNI value that was sent by the 2717f01e99SJung-uk Kimclient when the session was created if it was accepted by the server and TLSv1.2 2817f01e99SJung-uk Kimor below was negotiated. Otherwise NULL is returned. Note that in TLSv1.3 the 2917f01e99SJung-uk KimSNI hostname is negotiated with each handshake including resumption handshakes 3017f01e99SJung-uk Kimand is therefore never associated with the session. 31e71b7053SJung-uk Kim 32e71b7053SJung-uk KimThe value returned is a pointer to memory maintained within B<s> and 33e71b7053SJung-uk Kimshould not be free'd. 34e71b7053SJung-uk Kim 35e71b7053SJung-uk KimSSL_SESSION_set1_hostname() sets the SNI value for the hostname to a copy of 36e71b7053SJung-uk Kimthe string provided in hostname. 37e71b7053SJung-uk Kim 38e71b7053SJung-uk KimSSL_SESSION_get0_alpn_selected() retrieves the selected ALPN protocol for this 39e71b7053SJung-uk Kimsession and its associated length in bytes. The returned value of B<*alpn> is a 40e71b7053SJung-uk Kimpointer to memory maintained within B<s> and should not be free'd. 41e71b7053SJung-uk Kim 42e71b7053SJung-uk KimSSL_SESSION_set1_alpn_selected() sets the ALPN protocol for this session to the 43e71b7053SJung-uk Kimvalue in B<alpn> which should be of length B<len> bytes. A copy of the input 44e71b7053SJung-uk Kimvalue is made, and the caller retains ownership of the memory pointed to by 45e71b7053SJung-uk KimB<alpn>. 46e71b7053SJung-uk Kim 47e71b7053SJung-uk Kim=head1 RETURN VALUES 48e71b7053SJung-uk Kim 49e71b7053SJung-uk KimSSL_SESSION_get0_hostname() returns either a string or NULL based on if there 50e71b7053SJung-uk Kimis the SNI value sent by client. 51e71b7053SJung-uk Kim 52e71b7053SJung-uk KimSSL_SESSION_set1_hostname() returns 1 on success or 0 on error. 53e71b7053SJung-uk Kim 54e71b7053SJung-uk KimSSL_SESSION_set1_alpn_selected() returns 1 on success or 0 on error. 55e71b7053SJung-uk Kim 56e71b7053SJung-uk Kim=head1 SEE ALSO 57e71b7053SJung-uk Kim 58e71b7053SJung-uk KimL<ssl(7)>, 59e71b7053SJung-uk KimL<d2i_SSL_SESSION(3)>, 60e71b7053SJung-uk KimL<SSL_SESSION_get_time(3)>, 61e71b7053SJung-uk KimL<SSL_SESSION_free(3)> 62e71b7053SJung-uk Kim 63e71b7053SJung-uk Kim=head1 HISTORY 64e71b7053SJung-uk Kim 656935a639SJung-uk KimThe SSL_SESSION_set1_hostname(), SSL_SESSION_get0_alpn_selected() and 666935a639SJung-uk KimSSL_SESSION_set1_alpn_selected() functions were added in OpenSSL 1.1.1. 67e71b7053SJung-uk Kim 68e71b7053SJung-uk Kim=head1 COPYRIGHT 69e71b7053SJung-uk Kim 7017f01e99SJung-uk KimCopyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. 71e71b7053SJung-uk Kim 72*b077aed3SPierre ProncheryLicensed under the Apache License 2.0 (the "License"). You may not use 73e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 74e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 75e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 76e71b7053SJung-uk Kim 77e71b7053SJung-uk Kim=cut 78