1=pod 2 3=head1 NAME 4 5SSL_CTX_set_tlsext_servername_callback, SSL_CTX_set_tlsext_servername_arg, 6SSL_get_servername_type, SSL_get_servername, 7SSL_set_tlsext_host_name - handle server name indication (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 int SSL_set_tlsext_host_name(const SSL *s, const char *name); 21 22=head1 DESCRIPTION 23 24The functionality provided by the servername callback is superseded by the 25ClientHello callback, which can be set using SSL_CTX_set_client_hello_cb(). 26The servername callback is retained for historical compatibility. 27 28SSL_CTX_set_tlsext_servername_callback() sets the application callback B<cb> 29used by a server to perform any actions or configuration required based on 30the servername extension received in the incoming connection. When B<cb> 31is NULL, SNI is not used. The B<arg> value is a pointer which is passed to 32the application callback. 33 34SSL_CTX_set_tlsext_servername_arg() sets a context-specific argument to be 35passed into the callback for this B<SSL_CTX>. 36 37SSL_get_servername() returns a servername extension value of the specified 38type if provided in the Client Hello or NULL. 39 40SSL_get_servername_type() returns the servername type or -1 if no servername 41is present. Currently the only supported type (defined in RFC3546) is 42B<TLSEXT_NAMETYPE_host_name>. 43 44SSL_set_tlsext_host_name() sets the server name indication ClientHello extension 45to contain the value B<name>. The type of server name indication extension is set 46to B<TLSEXT_NAMETYPE_host_name> (defined in RFC3546). 47 48=head1 NOTES 49 50Several callbacks are executed during ClientHello processing, including 51the ClientHello, ALPN, and servername callbacks. The ClientHello callback is 52executed first, then the servername callback, followed by the ALPN callback. 53 54The SSL_set_tlsext_host_name() function should only be called on SSL objects 55that will act as clients; otherwise the configured B<name> will be ignored. 56 57=head1 RETURN VALUES 58 59SSL_CTX_set_tlsext_servername_callback() and 60SSL_CTX_set_tlsext_servername_arg() both always return 1 indicating success. 61SSL_set_tlsext_host_name() returns 1 on success, 0 in case of error. 62 63=head1 SEE ALSO 64 65L<ssl(7)>, L<SSL_CTX_set_alpn_select_cb(3)>, 66L<SSL_get0_alpn_selected(3)>, L<SSL_CTX_set_client_hello_cb(3)> 67 68=head1 COPYRIGHT 69 70Copyright 2017 The OpenSSL Project Authors. All Rights Reserved. 71 72Licensed under the OpenSSL license (the "License"). You may not use 73this file except in compliance with the License. You can obtain a copy 74in the file LICENSE in the source distribution or at 75L<https://www.openssl.org/source/license.html>. 76 77=cut 78