Update documentation
[openssl.git] / doc / man3 / SSL_CTX_set_tlsext_status_cb.pod
1 =pod
2
3 =head1 NAME
4
5 SSL_CTX_set_tlsext_status_cb,
6 SSL_CTX_get_tlsext_status_cb,
7 SSL_CTX_set_tlsext_status_arg,
8 SSL_CTX_get_tlsext_status_arg,
9 SSL_CTX_set_tlsext_status_type,
10 SSL_CTX_get_tlsext_status_type,
11 SSL_set_tlsext_status_type,
12 SSL_get_tlsext_status_type,
13 SSL_get_tlsext_status_ocsp_resp,
14 SSL_set_tlsext_status_ocsp_resp
15 - OCSP Certificate Status Request functions
16
17 =head1 SYNOPSIS
18
19  #include <openssl/tls1.h>
20
21  long SSL_CTX_set_tlsext_status_cb(SSL_CTX *ctx,
22                                    int (*callback)(SSL *, void *));
23  long SSL_CTX_get_tlsext_status_cb(SSL_CTX *ctx,
24                                    int (**callback)(SSL *, void *));
25
26  long SSL_CTX_set_tlsext_status_arg(SSL_CTX *ctx, void *arg);
27  long SSL_CTX_get_tlsext_status_arg(SSL_CTX *ctx, void **arg);
28
29  long SSL_CTX_set_tlsext_status_type(SSL_CTX *ctx, int type);
30  long SSL_CTX_get_tlsext_status_type(SSL_CTX *ctx);
31
32  long SSL_set_tlsext_status_type(SSL *s, int type);
33  long SSL_get_tlsext_status_type(SSL *s);
34
35  long SSL_get_tlsext_status_ocsp_resp(ssl, unsigned char **resp);
36  long SSL_set_tlsext_status_ocsp_resp(ssl, unsigned char *resp, int len);
37
38 =head1 DESCRIPTION
39
40 A client application may request that a server send back an OCSP status response
41 (also known as OCSP stapling). To do so the client should call the
42 SSL_CTX_set_tlsext_status_type() function prior to the creation of any SSL
43 objects. Alternatively an application can call the SSL_set_tlsext_status_type()
44 function on an individual SSL object prior to the start of the handshake.
45 Currently the only supported type is B<TLSEXT_STATUSTYPE_ocsp>. This value
46 should be passed in the B<type> argument. Calling
47 SSL_CTX_get_tlsext_status_type() will return the type B<TLSEXT_STATUSTYPE_ocsp>
48 previously set via SSL_CTX_set_tlsext_status_type() or -1 if not set.
49
50 The client should additionally provide a callback function to decide what to do
51 with the returned OCSP response by calling SSL_CTX_set_tlsext_status_cb(). The
52 callback function should determine whether the returned OCSP response is
53 acceptable or not. The callback will be passed as an argument the value
54 previously set via a call to SSL_CTX_set_tlsext_status_arg(). Note that the
55 callback will not be called in the event of a handshake where session resumption
56 occurs (because there are no Certificates exchanged in such a handshake).
57 The callback previously set via SSL_CTX_set_tlsext_status_cb() can be retrieved
58 by calling SSL_CTX_get_tlsext_status_cb(), and the argument by calling
59 SSL_CTX_get_tlsext_status_arg().
60
61 On the client side SSL_get_tlsext_status_type() can be used to determine whether
62 the client has previously called SSL_set_tlsext_status_type(). It will return
63 B<TLSEXT_STATUSTYPE_ocsp> if it has been called or -1 otherwise. On the server
64 side SSL_get_tlsext_status_type() can be used to determine whether the client
65 requested OCSP stapling. If the client requested it then this function will
66 return B<TLSEXT_STATUSTYPE_ocsp>, or -1 otherwise.
67
68 The response returned by the server can be obtained via a call to
69 SSL_get_tlsext_status_ocsp_resp(). The value B<*resp> will be updated to point
70 to the OCSP response data and the return value will be the length of that data.
71 Typically a callback would obtain an OCSP_RESPONSE object from this data via a
72 call to the d2i_OCSP_RESPONSE() function. If the server has not provided any
73 response data then B<*resp> will be NULL and the return value from
74 SSL_get_tlsext_status_ocsp_resp() will be -1.
75
76 A server application must also call the SSL_CTX_set_tlsext_status_cb() function
77 if it wants to be able to provide clients with OCSP Certificate Status
78 responses. Typically the server callback would obtain the server certificate
79 that is being sent back to the client via a call to SSL_get_certificate();
80 obtain the OCSP response to be sent back; and then set that response data by
81 calling SSL_set_tlsext_status_ocsp_resp(). A pointer to the response data should
82 be provided in the B<resp> argument, and the length of that data should be in
83 the B<len> argument.
84
85 =head1 RETURN VALUES
86
87 The callback when used on the client side should return a negative value on
88 error; 0 if the response is not acceptable (in which case the handshake will
89 fail) or a positive value if it is acceptable.
90
91 The callback when used on the server side should return with either
92 SSL_TLSEXT_ERR_OK (meaning that the OCSP response that has been set should be
93 returned), SSL_TLSEXT_ERR_NOACK (meaning that an OCSP response should not be
94 returned) or SSL_TLSEXT_ERR_ALERT_FATAL (meaning that a fatal error has
95 occurred).
96
97 SSL_CTX_set_tlsext_status_cb(), SSL_CTX_set_tlsext_status_arg(),
98 SSL_CTX_set_tlsext_status_type(), SSL_set_tlsext_status_type() and
99 SSL_set_tlsext_status_ocsp_resp() return 0 on error or 1 on success.
100
101 SSL_CTX_get_tlsext_status_type() returns the value previously set by
102 SSL_CTX_set_tlsext_status_type(), or -1 if not set.
103
104 SSL_get_tlsext_status_ocsp_resp() returns the length of the OCSP response data
105 or -1 if there is no OCSP response data.
106
107 SSL_get_tlsext_status_type() returns B<TLSEXT_STATUSTYPE_ocsp> on the client
108 side if SSL_set_tlsext_status_type() was previously called, or on the server
109 side if the client requested OCSP stapling. Otherwise -1 is returned.
110
111 =head1 HISTORY
112
113 SSL_get_tlsext_status_type(), SSL_CTX_get_tlsext_status_type() and
114 SSL_CTX_set_tlsext_status_type() were added in OpenSSL 1.1.0.
115
116 =head1 COPYRIGHT
117
118 Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
119
120 Licensed under the OpenSSL license (the "License").  You may not use
121 this file except in compliance with the License.  You can obtain a copy
122 in the file LICENSE in the source distribution or at
123 L<https://www.openssl.org/source/license.html>.
124
125 =cut