ldapssl_get_cert

Returns a certificate encoded in the requested format.

LDAP Version:v3
Library:*ldapssl.*
NDS Version:7.xx or higher
Platform:NLM, Windows (NT, 95, 98, 2000, XP, Vista 32-bit and 64-bit ), Linux (32-bit and 64-bit), Solaris, AIX, and HP-UX

Syntax

  #include <ldap_ssl.h>
  
  int ldapssl_get_cert (
     void           *certHandle,
     int             type,
     LDAPSSL_Cert   *cert);
  
  

Parameters

certHandle

(IN) certificate handle received by a verify callback function.

type

(IN) Desired certificate encoding. This must be one of the following values:

  • LDAPSSL_CERT_BUFFTYPE_B64

  • LDAPSSL_CERT_BUFFTYPE_DER

cert

(I/O) Pointer to an LDAPSSL_Cert structure.

Return Values

0

Success

-1

Failure

Remarks

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.

See Also

ldapssl_set_verify_callback, ldapssl_add_trusted_cert