Returns a certificate encoded in the requested format.
#include <ldap_ssl.h> int ldapssl_get_cert ( void *certHandle, int type, LDAPSSL_Cert *cert);
(IN) certificate handle received by a verify callback function.
(IN) Desired certificate encoding. This must be one of the following values:
LDAPSSL_CERT_BUFFTYPE_B64
LDAPSSL_CERT_BUFFTYPE_DER
(I/O) Pointer to an LDAPSSL_Cert structure.
Applications use ldapssl_get_cert to retrieve the certificate from the certificate handle passed to the ldapssl_set_verify_callback function.
The certHandle parameter is the certificate handle (void *) received by the verify callback routine.
An LDAPSSL_Cert structure contains two elements, length and data. The data element is a pointer to a buffer allocated by the application and length is the size of the buffer. To determine the correct size for the buffer, applications can pass in an LDAPSSL_Cert structure with the data element set to NULL and the length element will be updated with the appropriate size. The appropriate memory can then be allocated and ldapssl_get_cert can be called again with the LDAPSSL_Cert data element set to the allocated memory.
Applications can use ldapssl_get_cert to retrieve the certificate information as a buffer and use it a desired. One possibility is to add it to the list of trusted certificates using ldapssl_add_trusted_cert. After adding the certificate to the list of trusted certificates, the verify callback routine will no longer be called if the certificate is received when establishing future SSL connections.
For sample code, see sslbind_interactive.c.