1 1.1 christos =pod 2 1.1 christos 3 1.1 christos =head1 NAME 4 1.1 christos 5 1.1 christos SSL_get_certificate, SSL_get_privatekey - retrieve TLS/SSL certificate and 6 1.1 christos private key 7 1.1 christos 8 1.1 christos =head1 SYNOPSIS 9 1.1 christos 10 1.1 christos #include <openssl/ssl.h> 11 1.1 christos 12 1.1 christos X509 *SSL_get_certificate(const SSL *s); 13 1.1 christos EVP_PKEY *SSL_get_privatekey(const SSL *s); 14 1.1 christos 15 1.1 christos =head1 DESCRIPTION 16 1.1 christos 17 1.1 christos SSL_get_certificate() returns a pointer to an B<X509> object representing a 18 1.1 christos certificate used as the local peer's identity. 19 1.1 christos 20 1.1 christos Multiple certificates can be configured; for example, a server might have both 21 1.1 christos RSA and ECDSA certificates. The certificate which is returned by 22 1.1 christos SSL_get_certificate() is determined as follows: 23 1.1 christos 24 1.1 christos =over 4 25 1.1 christos 26 1.1 christos =item 27 1.1 christos 28 1.1 christos If it is called before certificate selection has occurred, it returns the most 29 1.1 christos recently added certificate, or NULL if no certificate has been added. 30 1.1 christos 31 1.1 christos =item 32 1.1 christos 33 1.1 christos After certificate selection has occurred, it returns the certificate which was 34 1.1 christos selected during the handshake, or NULL if no certificate was selected (for 35 1.1 christos example, on a client where no client certificate is in use). 36 1.1 christos 37 1.1 christos =back 38 1.1 christos 39 1.1 christos Certificate selection occurs during the handshake; therefore, the value returned 40 1.1 christos by SSL_get_certificate() during any callback made during the handshake process 41 1.1 christos will depend on whether that callback is made before or after certificate 42 1.1 christos selection occurs. 43 1.1 christos 44 1.1 christos A specific use for SSL_get_certificate() is inside a callback set via a call to 45 1.1 christos L<SSL_CTX_set_tlsext_status_cb(3)>. This callback occurs after certificate 46 1.1 christos selection, where it can be used to examine a server's chosen certificate, for 47 1.1 christos example for the purpose of identifying a certificate's OCSP responder URL so 48 1.1 christos that an OCSP response can be obtained. 49 1.1 christos 50 1.1 christos SSL_get_privatekey() returns a pointer to the B<EVP_PKEY> object corresponding 51 1.1 christos to the certificate returned by SSL_get_certificate(), if any. 52 1.1 christos 53 1.1 christos =head1 RETURN VALUES 54 1.1 christos 55 1.1 christos These functions return pointers to their respective objects, or NULL if no such 56 1.1 christos object is available. Returned objects are owned by the SSL object and should not 57 1.1 christos be freed by users of these functions. 58 1.1 christos 59 1.1 christos =head1 SEE ALSO 60 1.1 christos 61 1.1 christos L<ssl(7)>, L<SSL_CTX_set_tlsext_status_cb(3)> 62 1.1 christos 63 1.1 christos =head1 COPYRIGHT 64 1.1 christos 65 1.1 christos Copyright 2001-2022 The OpenSSL Project Authors. All Rights Reserved. 66 1.1 christos 67 1.1 christos Licensed under the Apache License 2.0 (the "License"). You may not use 68 1.1 christos this file except in compliance with the License. You can obtain a copy 69 1.1 christos in the file LICENSE in the source distribution or at 70 1.1 christos L<https://www.openssl.org/source/license.html>. 71 1.1 christos 72 1.1 christos =cut 73 1.1 christos 74