Add documentation for SNI APIs
[openssl.git] / doc / man3 / SSL_CTX_set_tlsext_servername_callback.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CTX_set_tlsext_servername_callback, SSL_CTX_set_tlsext_servername_arg,
6 SSL_get_servername_type, SSL_get_servername - handle server name indication
7 (SNI)
8
9 =head1 SYNOPSIS
10
11  #include <openssl/ssl.h>
12
13  long SSL_CTX_set_tlsext_servername_callback(SSL_CTX *ctx,
14                                    int (*cb)(SSL *, int *, void *));
15  long SSL_CTX_set_tlsext_servername_arg(SSL_CTX *ctx, void *arg);
16
17  const char *SSL_get_servername(const SSL *s, const int type);
18  int SSL_get_servername_type(const SSL *s);
19
20 =head1 DESCRIPTION
21
22 SSL_CTX_set_tlsext_servername_callback() sets the application callback B<cb>
23 used by a server to perform any actions or configuration required based on
24 the servername extension received in the incoming connection. When B<cb>
25 is NULL, SNI is not used. The B<arg> value is a pointer which is passed to
26 the application callback.
27
28 SSL_CTX_set_tlsext_servername_arg() sets a context-specific argument to be
29 passed into the callback for this B<SSL_CTX>.
30
31 SSL_get_servername() returns a servername extension value of the specified
32 type if provided in the Client Hello or NULL.
33
34 SSL_get_servername_type() returns the servername type or -1 if no servername
35 is present. Currently the only supported type (defined in RFC3546) is
36 B<TLSEXT_NAMETYPE_host_name>.
37
38 =head1 NOTES
39
40 The ALPN and SNI callbacks are both executed during Client Hello processing.
41 The servername callback is executed first, followed by the ALPN callback.
42
43 =head1 RETURN VALUES
44
45 SSL_CTX_set_tlsext_servername_callback() and
46 SSL_CTX_set_tlsext_servername_arg() both always return 1 indicating success.
47
48 =head1 SEE ALSO
49
50 L<ssl(7)>, L<SSL_CTX_set_alpn_select_cb(3)>,
51 L<SSL_get0_alpn_selected(3)>
52
53 =head1 COPYRIGHT
54
55 Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
56
57 Licensed under the OpenSSL license (the "License").  You may not use
58 this file except in compliance with the License.  You can obtain a copy
59 in the file LICENSE in the source distribution or at
60 L<https://www.openssl.org/source/license.html>.
61
62 =cut