1SSL_CTX_SET_CERT_CB(3) OpenSSL SSL_CTX_SET_CERT_CB(3)
2
3
4
6 SSL_CTX_set_cert_cb, SSL_set_cert_cb - handle certificate callback
7 function
8
10 #include <openssl/ssl.h>
11
12 void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cert_cb)(SSL *ssl, void *arg),
13 void *arg);
14 void SSL_set_cert_cb(SSL *s, int (*cert_cb)(SSL *ssl, void *arg), void *arg);
15
16 int (*cert_cb)(SSL *ssl, void *arg);
17
19 SSL_CTX_set_cert_cb() and SSL_set_cert_cb() sets the cert_cb()
20 callback, arg value is pointer which is passed to the application
21 callback.
22
23 When cert_cb() is NULL, no callback function is used.
24
25 cert_cb() is the application defined callback. It is called before a
26 certificate will be used by a client or server. The callback can then
27 inspect the passed ssl structure and set or clear any appropriate
28 certificates. If the callback is successful it MUST return 1 even if no
29 certificates have been set. A zero is returned on error which will
30 abort the handshake with a fatal internal error alert. A negative
31 return value will suspend the handshake and the handshake function will
32 return immediately. SSL_get_error(3) will return
33 SSL_ERROR_WANT_X509_LOOKUP to indicate, that the handshake was
34 suspended. The next call to the handshake function will again lead to
35 the call of cert_cb(). It is the job of the cert_cb() to store
36 information about the state of the last call, if required to continue.
37
39 An application will typically call SSL_use_certificate() and
40 SSL_use_PrivateKey() to set the end entity certificate and private key.
41 It can add intermediate and optionally the root CA certificates using
42 SSL_add1_chain_cert().
43
44 It might also call SSL_certs_clear() to delete any certificates
45 associated with the SSL object.
46
47 The certificate callback functionality supersedes the (largely broken)
48 functionality provided by the old client certificate callback
49 interface. It is always called even is a certificate is already set so
50 the callback can modify or delete the existing certificate.
51
52 A more advanced callback might examine the handshake parameters and set
53 whatever chain is appropriate. For example a legacy client supporting
54 only TLSv1.0 might receive a certificate chain signed using SHA1
55 whereas a TLSv1.2 or later client which advertises support for SHA256
56 could receive a chain using SHA256.
57
58 Normal server sanity checks are performed on any certificates set by
59 the callback. So if an EC chain is set for a curve the client does not
60 support it will not be used.
61
63 SSL_CTX_set_cert_cb() and SSL_set_cert_cb() do not return values.
64
66 ssl(7), SSL_use_certificate(3), SSL_add1_chain_cert(3),
67 SSL_get_client_CA_list(3), SSL_clear(3), SSL_free(3)
68
70 Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
71
72 Licensed under the OpenSSL license (the "License"). You may not use
73 this file except in compliance with the License. You can obtain a copy
74 in the file LICENSE in the source distribution or at
75 <https://www.openssl.org/source/license.html>.
76
77
78
791.1.1i 2021-01-26 SSL_CTX_SET_CERT_CB(3)