1SSL_CTX_SET_CLIENT_CERT_CB(3)       OpenSSL      SSL_CTX_SET_CLIENT_CERT_CB(3)
2
3
4

NAME

6       SSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb - handle client
7       certificate callback function
8

SYNOPSIS

10        #include <openssl/ssl.h>
11
12        void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,
13                                        int (*client_cert_cb)(SSL *ssl, X509 **x509,
14                                                              EVP_PKEY **pkey));
15        int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509,
16                                                        EVP_PKEY **pkey);
17        int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);
18

DESCRIPTION

20       SSL_CTX_set_client_cert_cb() sets the client_cert_cb() callback, that
21       is called when a client certificate is requested by a server and no
22       certificate was yet set for the SSL object.
23
24       When client_cert_cb() is NULL, no callback function is used.
25
26       SSL_CTX_get_client_cert_cb() returns a pointer to the currently set
27       callback function.
28
29       client_cert_cb() is the application defined callback. If it wants to
30       set a certificate, a certificate/private key combination must be set
31       using the x509 and pkey arguments and "1" must be returned. The
32       certificate will be installed into ssl, see the NOTES and BUGS
33       sections.  If no certificate should be set, "0" has to be returned and
34       no certificate will be sent. A negative return value will suspend the
35       handshake and the handshake function will return immediately.
36       SSL_get_error(3) will return SSL_ERROR_WANT_X509_LOOKUP to indicate,
37       that the handshake was suspended. The next call to the handshake
38       function will again lead to the call of client_cert_cb(). It is the job
39       of the client_cert_cb() to store information about the state of the
40       last call, if required to continue.
41

NOTES

43       During a handshake (or renegotiation) a server may request a
44       certificate from the client. A client certificate must only be sent,
45       when the server did send the request.
46
47       When a certificate was set using the SSL_CTX_use_certificate(3) family
48       of functions, it will be sent to the server. The TLS standard requires
49       that only a certificate is sent, if it matches the list of acceptable
50       CAs sent by the server. This constraint is violated by the default
51       behavior of the OpenSSL library. Using the callback function it is
52       possible to implement a proper selection routine or to allow a user
53       interaction to choose the certificate to be sent.
54
55       If a callback function is defined and no certificate was yet defined
56       for the SSL object, the callback function will be called.  If the
57       callback function returns a certificate, the OpenSSL library will try
58       to load the private key and certificate data into the SSL object using
59       the SSL_use_certificate() and SSL_use_private_key() functions.  Thus it
60       will permanently install the certificate and key for this SSL object.
61       It will not be reset by calling SSL_clear(3).  If the callback returns
62       no certificate, the OpenSSL library will not send a certificate.
63

RETURN VALUES

65       SSL_CTX_get_client_cert_cb() returns function pointer of
66       client_cert_cb() or NULL if the callback is not set.
67

BUGS

69       The client_cert_cb() cannot return a complete certificate chain, it can
70       only return one client certificate. If the chain only has a length of
71       2, the root CA certificate may be omitted according to the TLS standard
72       and thus a standard conforming answer can be sent to the server. For a
73       longer chain, the client must send the complete chain (with the option
74       to leave out the root CA certificate). This can only be accomplished by
75       either adding the intermediate CA certificates into the trusted
76       certificate store for the SSL_CTX object (resulting in having to add CA
77       certificates that otherwise maybe would not be trusted), or by adding
78       the chain certificates using the SSL_CTX_add_extra_chain_cert(3)
79       function, which is only available for the SSL_CTX object as a whole and
80       that therefore probably can only apply for one client certificate,
81       making the concept of the callback function (to allow the choice from
82       several certificates) questionable.
83
84       Once the SSL object has been used in conjunction with the callback
85       function, the certificate will be set for the SSL object and will not
86       be cleared even when SSL_clear(3) is being called. It is therefore
87       mandatory to destroy the SSL object using SSL_free(3) and create a new
88       one to return to the previous state.
89

SEE ALSO

91       ssl(7), SSL_CTX_use_certificate(3), SSL_CTX_add_extra_chain_cert(3),
92       SSL_get_client_CA_list(3), SSL_clear(3), SSL_free(3)
93
95       Copyright 2002-2018 The OpenSSL Project Authors. All Rights Reserved.
96
97       Licensed under the OpenSSL license (the "License").  You may not use
98       this file except in compliance with the License.  You can obtain a copy
99       in the file LICENSE in the source distribution or at
100       <https://www.openssl.org/source/license.html>.
101
102
103
1041.1.1i                            2021-01-26     SSL_CTX_SET_CLIENT_CERT_CB(3)
Impressum