1SSL_SESSION_GET0_HOSTNAME(3) OpenSSL SSL_SESSION_GET0_HOSTNAME(3)
2
3
4
6 SSL_SESSION_get0_hostname, SSL_SESSION_set1_hostname,
7 SSL_SESSION_get0_alpn_selected, SSL_SESSION_set1_alpn_selected - get
8 and set SNI and ALPN data associated with a session
9
11 #include <openssl/ssl.h>
12
13 const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s);
14 int SSL_SESSION_set1_hostname(SSL_SESSION *s, const char *hostname);
15
16 void SSL_SESSION_get0_alpn_selected(const SSL_SESSION *s,
17 const unsigned char **alpn,
18 size_t *len);
19 int SSL_SESSION_set1_alpn_selected(SSL_SESSION *s, const unsigned char *alpn,
20 size_t len);
21
23 SSL_SESSION_get0_hostname() retrieves the SNI value that was sent by
24 the client when the session was created if it was accepted by the
25 server and TLSv1.2 or below was negotiated. Otherwise NULL is returned.
26 Note that in TLSv1.3 the SNI hostname is negotiated with each handshake
27 including resumption handshakes and is therefore never associated with
28 the session.
29
30 The value returned is a pointer to memory maintained within s and
31 should not be free'd.
32
33 SSL_SESSION_set1_hostname() sets the SNI value for the hostname to a
34 copy of the string provided in hostname.
35
36 SSL_SESSION_get0_alpn_selected() retrieves the selected ALPN protocol
37 for this session and its associated length in bytes. The returned value
38 of *alpn is a pointer to memory maintained within s and should not be
39 free'd.
40
41 SSL_SESSION_set1_alpn_selected() sets the ALPN protocol for this
42 session to the value in alpn which should be of length len bytes. A
43 copy of the input value is made, and the caller retains ownership of
44 the memory pointed to by alpn.
45
47 SSL_SESSION_get0_hostname() returns either a string or NULL based on if
48 there is the SNI value sent by client.
49
50 SSL_SESSION_set1_hostname() returns 1 on success or 0 on error.
51
52 SSL_SESSION_set1_alpn_selected() returns 1 on success or 0 on error.
53
55 ssl(7), d2i_SSL_SESSION(3), SSL_SESSION_get_time(3),
56 SSL_SESSION_free(3)
57
59 The SSL_SESSION_set1_hostname(), SSL_SESSION_get0_alpn_selected() and
60 SSL_SESSION_set1_alpn_selected() functions were added in OpenSSL 1.1.1.
61
63 Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved.
64
65 Licensed under the OpenSSL license (the "License"). You may not use
66 this file except in compliance with the License. You can obtain a copy
67 in the file LICENSE in the source distribution or at
68 <https://www.openssl.org/source/license.html>.
69
70
71
721.1.1g 2020-04-23 SSL_SESSION_GET0_HOSTNAME(3)