xref: /freebsd/crypto/openssl/doc/man3/SSL_SESSION_get0_hostname.pod (revision 1ddff51060ad759e35dcc4716b0bdcdb40255862)
1=pod
2
3=head1 NAME
4
5SSL_SESSION_get0_hostname,
6SSL_SESSION_set1_hostname,
7SSL_SESSION_get0_alpn_selected,
8SSL_SESSION_set1_alpn_selected
9- get and set SNI and ALPN data associated with a session
10
11=head1 SYNOPSIS
12
13 #include <openssl/ssl.h>
14
15 const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);
16 int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);
17
18 void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,
19                                     const unsigned char **alpn,
20                                     size_t *len);
21 int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, const unsigned char *alpn,
22                                    size_t len);
23
24=head1 DESCRIPTION
25
26SSL_SESSION_get0_hostname() retrieves the Server Name Indication (SNI) value
27that was sent by the client when the session was created if the server
28acknowledged the client's SNI extension by including an empty SNI extension
29in response. Otherwise NULL is returned.
30
31The value returned is a pointer to memory maintained within B<s> and
32should not be free'd.
33
34SSL_SESSION_set1_hostname() sets the SNI value for the hostname to a copy of
35the string provided in hostname.
36
37SSL_SESSION_get0_alpn_selected() retrieves the selected ALPN protocol for this
38session and its associated length in bytes. The returned value of B<*alpn> is a
39pointer to memory maintained within B<s> and should not be free'd.
40
41SSL_SESSION_set1_alpn_selected() sets the ALPN protocol for this session to the
42value in B<alpn> which should be of length B<len> bytes. A copy of the input
43value is made, and the caller retains ownership of the memory pointed to by
44B<alpn>.
45
46=head1 RETURN VALUES
47
48SSL_SESSION_get0_hostname() returns the SNI string if available, or NULL if not.
49
50SSL_SESSION_set1_hostname() returns 1 on success or 0 on error.
51
52SSL_SESSION_set1_alpn_selected() returns 1 on success or 0 on error.
53
54=head1 SEE ALSO
55
56L<ssl(7)>,
57L<d2i_SSL_SESSION(3)>,
58L<SSL_SESSION_get_time(3)>,
59L<SSL_SESSION_free(3)>
60
61=head1 HISTORY
62
63The SSL_SESSION_set1_hostname(), SSL_SESSION_get0_alpn_selected() and
64SSL_SESSION_set1_alpn_selected() functions were added in OpenSSL 1.1.1.
65
66=head1 COPYRIGHT
67
68Copyright 2016-2025 The OpenSSL Project Authors. All Rights Reserved.
69
70Licensed under the Apache License 2.0 (the "License").  You may not use
71this file except in compliance with the License.  You can obtain a copy
72in the file LICENSE in the source distribution or at
73L<https://www.openssl.org/source/license.html>.
74
75=cut
76