Blame doc/man3/SSL_CTX_set_cert_cb.pod

Packit c4476c
=pod
Packit c4476c
Packit c4476c
=head1 NAME
Packit c4476c
Packit c4476c
SSL_CTX_set_cert_cb, SSL_set_cert_cb - handle certificate callback function
Packit c4476c
Packit c4476c
=head1 SYNOPSIS
Packit c4476c
Packit c4476c
 #include <openssl/ssl.h>
Packit c4476c
Packit c4476c
 void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cert_cb)(SSL *ssl, void *arg),
Packit c4476c
                          void *arg);
Packit c4476c
 void SSL_set_cert_cb(SSL *s, int (*cert_cb)(SSL *ssl, void *arg), void *arg);
Packit c4476c
Packit c4476c
 int (*cert_cb)(SSL *ssl, void *arg);
Packit c4476c
Packit c4476c
=head1 DESCRIPTION
Packit c4476c
Packit c4476c
SSL_CTX_set_cert_cb() and SSL_set_cert_cb() sets the cert_cb() callback,
Packit c4476c
B<arg> value is pointer which is passed to the application callback.
Packit c4476c
Packit c4476c
When cert_cb() is NULL, no callback function is used.
Packit c4476c
Packit c4476c
cert_cb() is the application defined callback. It is called before a
Packit c4476c
certificate will be used by a client or server. The callback can then inspect
Packit c4476c
the passed B<ssl> structure and set or clear any appropriate certificates. If
Packit c4476c
the callback is successful it B<MUST> return 1 even if no certificates have
Packit c4476c
been set. A zero is returned on error which will abort the handshake with a
Packit c4476c
fatal internal error alert. A negative return value will suspend the handshake
Packit c4476c
and the handshake function will return immediately.
Packit c4476c
L<SSL_get_error(3)> will return SSL_ERROR_WANT_X509_LOOKUP to
Packit c4476c
indicate, that the handshake was suspended. The next call to the handshake
Packit c4476c
function will again lead to the call of cert_cb(). It is the job of the
Packit c4476c
cert_cb() to store information about the state of the last call,
Packit c4476c
if required to continue.
Packit c4476c
Packit c4476c
=head1 NOTES
Packit c4476c
Packit c4476c
An application will typically call SSL_use_certificate() and
Packit c4476c
SSL_use_PrivateKey() to set the end entity certificate and private key.
Packit c4476c
It can add intermediate and optionally the root CA certificates using
Packit c4476c
SSL_add1_chain_cert().
Packit c4476c
Packit c4476c
It might also call SSL_certs_clear() to delete any certificates associated
Packit c4476c
with the B<SSL> object.
Packit c4476c
Packit c4476c
The certificate callback functionality supersedes the (largely broken)
Packit c4476c
functionality provided by the old client certificate callback interface.
Packit c4476c
It is B<always> called even is a certificate is already set so the callback
Packit c4476c
can modify or delete the existing certificate.
Packit c4476c
Packit c4476c
A more advanced callback might examine the handshake parameters and set
Packit c4476c
whatever chain is appropriate. For example a legacy client supporting only
Packit c4476c
TLSv1.0 might receive a certificate chain signed using SHA1 whereas a
Packit c4476c
TLSv1.2 or later client which advertises support for SHA256 could receive a
Packit c4476c
chain using SHA256.
Packit c4476c
Packit c4476c
Normal server sanity checks are performed on any certificates set
Packit c4476c
by the callback. So if an EC chain is set for a curve the client does not
Packit c4476c
support it will B<not> be used.
Packit c4476c
Packit c4476c
=head1 RETURN VALUES
Packit c4476c
Packit c4476c
SSL_CTX_set_cert_cb() and SSL_set_cert_cb() do not return values.
Packit c4476c
Packit c4476c
=head1 SEE ALSO
Packit c4476c
Packit c4476c
L<ssl(7)>, L<SSL_use_certificate(3)>,
Packit c4476c
L<SSL_add1_chain_cert(3)>,
Packit c4476c
L<SSL_get_client_CA_list(3)>,
Packit c4476c
L<SSL_clear(3)>, L<SSL_free(3)>
Packit c4476c
Packit c4476c
=head1 COPYRIGHT
Packit c4476c
Packit c4476c
Copyright 2014-2018 The OpenSSL Project Authors. All Rights Reserved.
Packit c4476c
Packit c4476c
Licensed under the OpenSSL license (the "License").  You may not use
Packit c4476c
this file except in compliance with the License.  You can obtain a copy
Packit c4476c
in the file LICENSE in the source distribution or at
Packit c4476c
L<https://www.openssl.org/source/license.html>.
Packit c4476c
Packit c4476c
=cut