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