table of contents
| SSL_CTX_SET_CLIENT_CERT_CB(3SSL) | OpenSSL | SSL_CTX_SET_CLIENT_CERT_CB(3SSL) |
NOM¶
SSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb - Gestion de la fonction de rappel de certificat client.
SYNOPSIS¶
#include <openssl/ssl.h>
void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx,
int (*client_cert_cb)(SSL *ssl, X509 **x509,
EVP_PKEY **pkey));
int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx))(SSL *ssl, X509 **x509,
EVP_PKEY **pkey);
DESCRIPTION¶
SSL_CTX_set_client_cert_cb() définit le rappel client_cert_cb, qui est appelé lors d’une demande de certificat client par un serveur et qu’aucun certificat n’a été défini pour l’objet SSL.
Lorsque client_cert_cb() est NULL, aucune fonction de rappel n’est utilisée.
SSL_CTX_ge_client_cert_cb() renvoie un pointeur vers la fonction de rappel actuellement définie.
client_cert_cb est le rappel défini par l’application. Si elle veut définir un certificat, une combinaison clef/certificat privé doit être indiquée en utilisant les arguments x509 et pkey, et 1 doit être renvoyé. Le certificat sera installé dans ssl ; consultez les sections NOTES et BOGUES. Si aucun certificat ne doit être défini, 0 doit être renvoyé et aucun certificat ne sera adressé. Le renvoi d’une valeur négative suspendra l’initiation de connexion et la fonction d’initiation s'arrêtera immédiatement. SSL_get_error(3) renverra SSL_ERROR_WANT_X509_LOOKUP pour signaler que l’initiation est suspendue. Le prochain appel à la fonction d’initiation amènera de nouveau à l’appel de client_cert_cb. C’est au client_cert_cb d’emmagasiner l’information sur l’état du dernier appel, si une demande de continuation est faite.
NOTES¶
Pendant l’initialisation de connexion (ou renégociation), un serveur peut demander un certificat au client. Un certificat client doit seulement être adressé, lorsque le serveur a bien envoyé la requête.
Quand un certificat a été défini en utilisant la famille de fonctions SSL_CTX_use_certificate(3), il est adressé au serveur. La norme TLS exige qu’un seul certificat soit adressé, s’il a une correspondance dans la liste de CA acceptables envoyée par le serveur. Cette contrainte n’est pas respectée par le comportement par défaut de la bibliothèque OpenSSL. L’utilisation de la fonction de rappel permet d’implémenter une routine de sélection appropriée ou de choisir le certificat à envoyer par une interaction de l’utilisateur.
Si une fonction de rappel est définie et qu’aucun certificat n’a été défini pour l’objet SSL, la fonction de rappel est appelée. Si la fonction de rappel renvoie un certificat, la bibliothèque OpenSSL essayera de charger la clef privée et les données de certificat dans l’objet SSL, en utilisant les fonctions SSL_use_certificate() et SSL_use_private_key(). Par conséquent, les clef et certificat seront installés définitivement pour l’objet SSL. Ils ne seront pas réinitialisés par SSL_clear(3). Si le rappel ne renvoie aucun certificat, la bibliothèque OpenSSl n’adressera pas de certificat.
VALEURS RENVOYÉES¶
SSL_CTX_get_client_cert_cb() returns function pointer of client_cert_cb or NULL if the callback is not set.
BOGUES¶
The client_cert_cb cannot return a complete certificate chain, it can only return one client certificate. If the chain only has a length of 2, the root CA certificate may be omitted according to the TLS standard and thus a standard conforming answer can be sent to the server. For a longer chain, the client must send the complete chain (with the option to leave out the root CA certificate). This can only be accomplished by either adding the intermediate CA certificates into the trusted certificate store for the SSL_CTX object (resulting in having to add CA certificates that otherwise maybe would not be trusted), or by adding the chain certificates using the SSL_CTX_add_extra_chain_cert(3) function, which is only available for the SSL_CTX object as a whole and that therefore probably can only apply for one client certificate, making the concept of the callback function (to allow the choice from several certificates) questionable.
Once the SSL object has been used in conjunction with the callback function, the certificate will be set for the SSL object and will not be cleared even when SSL_clear(3) is being called. It is therefore mandatory to destroy the SSL object using SSL_free(3) and create a new one to return to the previous state.
VOIR AUSSI¶
ssl(7), SSL_CTX_use_certificate(3), SSL_CTX_add_extra_chain_cert(3), SSL_get_client_CA_list(3), SSL_clear(3), SSL_free(3)
COPYRIGHT¶
Copyright 2002-2020 Les auteurs du projet OpenSSL. Tous droits réservés.
Sous licence Apache 2.0 (la « Licence »). Vous ne pouvez utiliser ce fichier que conformément à la Licence. Vous trouverez une copie dans le fichier LICENSE de la distribution du source ou à l'adresse <https://www.openssl.org/source/license.html>.
TRADUCTION¶
La traduction française de cette page de manuel a été créée par Nicolas François <nicolas.francois@centraliens.net>, David Prévot <david@tilapin.org> et Jean-Paul Guillonneau <guillonneau.jeanpaul@free.fr>
Cette traduction est une documentation libre ; veuillez vous reporter à la GNU General Public License version 3 concernant les conditions de copie et de distribution. Il n'y a aucune RESPONSABILITÉ LÉGALE.
Si vous découvrez un bogue dans la traduction de cette page de manuel, veuillez envoyer un message à debian-l10n-french@lists.debian.org.
| 29 septembre 2026 | 3.6.5 |