1SSL_CTX_set_custom_cli_ext(3)       OpenSSL      SSL_CTX_set_custom_cli_ext(3)
2
3
4

NAME

6       SSL_CTX_add_client_custom_ext, SSL_CTX_add_server_custom_ext - custom
7       TLS extension handling
8

SYNOPSIS

10        #include <openssl/ssl.h>
11
12        int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
13                                          custom_ext_add_cb add_cb,
14                                          custom_ext_free_cb free_cb, void *add_arg,
15                                          custom_ext_parse_cb parse_cb,
16                                          void *parse_arg);
17
18        int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type,
19                                          custom_ext_add_cb add_cb,
20                                          custom_ext_free_cb free_cb, void *add_arg,
21                                          custom_ext_parse_cb parse_cb,
22                                          void *parse_arg);
23
24        int SSL_extension_supported(unsigned int ext_type);
25
26        typedef int (*custom_ext_add_cb)(SSL *s, unsigned int ext_type,
27                                         const unsigned char **out,
28                                         size_t *outlen, int *al,
29                                         void *add_arg);
30
31        typedef void (*custom_ext_free_cb)(SSL *s, unsigned int ext_type,
32                                           const unsigned char *out,
33                                           void *add_arg);
34
35        typedef int (*custom_ext_parse_cb)(SSL *s, unsigned int ext_type,
36                                           const unsigned char *in,
37                                           size_t inlen, int *al,
38                                           void *parse_arg);
39

DESCRIPTION

41       SSL_CTX_add_client_custom_ext() adds a custom extension for a TLS
42       client with extension type ext_type and callbacks add_cb, free_cb and
43       parse_cb.
44
45       SSL_CTX_add_server_custom_ext() adds a custom extension for a TLS
46       server with extension type ext_type and callbacks add_cb, free_cb and
47       parse_cb.
48
49       In both cases the extension type must not be handled by OpenSSL
50       internally or an error occurs.
51
52       SSL_extension_supported() returns 1 if the extension ext_type is
53       handled internally by OpenSSL and 0 otherwise.
54

EXTENSION CALLBACKS

56       The callback add_cb is called to send custom extension data to be
57       included in ClientHello for TLS clients or ServerHello for servers. The
58       ext_type parameter is set to the extension type which will be added and
59       add_arg to the value set when the extension handler was added.
60
61       If the application wishes to include the extension ext_type it should
62       set *out to the extension data, set *outlen to the length of the
63       extension data and return 1.
64
65       If the add_cb does not wish to include the extension it must return 0.
66
67       If add_cb returns -1 a fatal handshake error occurs using the TLS alert
68       value specified in *al.
69
70       For clients (but not servers) if add_cb is set to NULL a zero length
71       extension is added for ext_type.
72
73       For clients every registered add_cb is always called to see if the
74       application wishes to add an extension to ClientHello.
75
76       For servers every registered add_cb is called once if and only if the
77       corresponding extension was received in ClientHello to see if the
78       application wishes to add the extension to ServerHello. That is, if no
79       corresponding extension was received in ClientHello then add_cb will
80       not be called.
81
82       If an extension is added (that is add_cb returns 1) free_cb is called
83       (if it is set) with the value of out set by the add callback. It can be
84       used to free up any dynamic extension data set by add_cb. Since out is
85       constant (to permit use of constant data in add_cb) applications may
86       need to cast away const to free the data.
87
88       The callback parse_cb receives data for TLS extensions. For TLS clients
89       the extension data will come from ServerHello and for TLS servers it
90       will come from ClientHello.
91
92       The extension data consists of inlen bytes in the buffer in for the
93       extension extension_type.
94
95       If the parse_cb considers the extension data acceptable it must return
96       1. If it returns 0 or a negative value a fatal handshake error occurs
97       using the TLS alert value specified in *al.
98
99       The buffer in is a temporary internal buffer which will not be valid
100       after the callback returns.
101

NOTES

103       The add_arg and parse_arg parameters can be set to arbitrary values
104       which will be passed to the corresponding callbacks. They can, for
105       example, be used to store the extension data received in a convenient
106       structure or pass the extension data to be added or freed when adding
107       extensions.
108
109       The ext_type parameter corresponds to the extension_type field of
110       RFC5246 et al. It is not a NID.
111
112       If the same custom extension type is received multiple times a fatal
113       decode_error alert is sent and the handshake aborts. If a custom
114       extension is received in ServerHello which was not sent in ClientHello
115       a fatal unsupported_extension alert is sent and the handshake is
116       aborted. The ServerHello add_cb callback is only called if the
117       corresponding extension was received in ClientHello. This is compliant
118       with the TLS specifications.  This behaviour ensures that each callback
119       is called at most once and that an application can never send
120       unsolicited extensions.
121

RETURN VALUES

123       SSL_CTX_add_client_custom_ext() and SSL_CTX_add_server_custom_ext()
124       return 1 for success and 0 for failure. A failure can occur if an
125       attempt is made to add the same ext_type more than once, if an attempt
126       is made to use an extension type handled internally by OpenSSL or if an
127       internal error occurs (for example a memory allocation failure).
128
129       SSL_extension_supported() returns 1 if the extension ext_type is
130       handled internally by OpenSSL and 0 otherwise.
131
132
133
1341.0.2o                            2020-01-28     SSL_CTX_set_custom_cli_ext(3)
Impressum