⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssl_ctx_set_client_cert_cb.pod

📁 开源的ssl算法openssl,版本0.9.8H
💻 POD
字号:
=pod=head1 NAMESSL_CTX_set_client_cert_cb, SSL_CTX_get_client_cert_cb - handle client certificate callback function=head1 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); int (*client_cert_cb)(SSL *ssl, X509 **x509, EVP_PKEY **pkey);=head1 DESCRIPTIONSSL_CTX_set_client_cert_cb() sets the B<client_cert_cb()> callback, that iscalled when a client certificate is requested by a server and no certificatewas yet set for the SSL object.When B<client_cert_cb()> is NULL, no callback function is used.SSL_CTX_get_client_cert_cb() returns a pointer to the currently set callbackfunction.client_cert_cb() is the application defined callback. If it wants toset a certificate, a certificate/private key combination must be setusing the B<x509> and B<pkey> arguments and "1" must be returned. Thecertificate will be installed into B<ssl>, see the NOTES and BUGS sections.If no certificate should be set, "0" has to be returned and no certificatewill be sent. A negative return value will suspend the handshake and thehandshake function will return immediatly. L<SSL_get_error(3)|SSL_get_error(3)>will return SSL_ERROR_WANT_X509_LOOKUP to indicate, that the handshake wassuspended. The next call to the handshake function will again lead to the callof client_cert_cb(). It is the job of the client_cert_cb() to store informationabout the state of the last call, if required to continue.=head1 NOTESDuring a handshake (or renegotiation) a server may request a certificatefrom the client. A client certificate must only be sent, when the serverdid send the request.When a certificate was set using theL<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)> family of functions,it will be sent to the server. The TLS standard requires that only acertificate is sent, if it matches the list of acceptable CAs sent by theserver. This constraint is violated by the default behavior of the OpenSSLlibrary. Using the callback function it is possible to implement a properselection routine or to allow a user interaction to choose the certificate tobe sent.If a callback function is defined and no certificate was yet defined for theSSL object, the callback function will be called.If the callback function returns a certificate, the OpenSSL librarywill try to load the private key and certificate data into the SSLobject using the SSL_use_certificate() and SSL_use_private_key() functions.Thus it will permanently install the certificate and key for this SSLobject. It will not be reset by calling L<SSL_clear(3)|SSL_clear(3)>.If the callback returns no certificate, the OpenSSL library will not senda certificate.=head1 BUGSThe client_cert_cb() cannot return a complete certificate chain, it canonly 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 andthus a standard conforming answer can be sent to the server. For alonger chain, the client must send the complete chain (with the optionto leave out the root CA certificate). This can only be accomplished byeither adding the intermediate CA certificates into the trustedcertificate store for the SSL_CTX object (resulting in having to addCA certificates that otherwise maybe would not be trusted), or by addingthe chain certificates using theL<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>function, which is only available for the SSL_CTX object as a whole and thattherefore probably can only apply for one client certificate, makingthe concept of the callback function (to allow the choice from severalcertificates) 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 clearedeven when L<SSL_clear(3)|SSL_clear(3)> is being called. It is thereforemandatory to destroy the SSL object using L<SSL_free(3)|SSL_free(3)>and create a new one to return to the previous state.=head1 SEE ALSOL<ssl(3)|ssl(3)>, L<SSL_CTX_use_certificate(3)|SSL_CTX_use_certificate(3)>,L<SSL_CTX_add_extra_chain_cert(3)|SSL_CTX_add_extra_chain_cert(3)>,L<SSL_get_client_CA_list(3)|SSL_get_client_CA_list(3)>,L<SSL_clear(3)|SSL_clear(3)>, L<SSL_free(3)|SSL_free(3)>=cut

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -