gnutls_certificate_set_retrieve_function - Linux


Overview

gnutls_certificate_set_retrieve_function configures a TLS certificate to use a callback function to retrieve the certificate, allowing dynamic retrieval of certificates at runtime.

Syntax

gnutls_certificate_set_retrieve_function(cert, retrieve_function, user_data)

Options/Flags

  • retrieve_function: Function to call to retrieve the certificate. The function should accept two arguments: a gnutls_certificate_credentials_t pointer and a user_data pointer. It should return a pointer to a gnutls_certificate_t object or NULL if it cannot retrieve a certificate.
  • user_data: User-defined data to pass to the retrieve_function.

Examples

static int retrieve_certificate(gnutls_certificate_credentials_t credentials, void *usr_data)
{
  // Your code to retrieve the certificate.
}

gnutls_certificate_credentials_t cert;
gnutls_certificate_set_retrieve_function(cert, retrieve_certificate, NULL);

Common Issues

  • Ensure that the retrieve_function is able to retrieve the certificate as needed.

Integration

gnutls_certificate_set_retrieve_function is used to dynamically retrieve certificates at runtime, which can be useful for applications that need to support multiple certificates or for applications that want to retrieve certificates from a remote location.

Related Commands

  • gnutls_certificate_set_verify_function: Configures a certificate to use a callback function to verify the certificate instead of the default verification function.
  • gnutls_certificate_set_stapling_verify_function: Configures a certificate to use a callback function to verify stapling instead of the default verification function.