NAME

catssl_setdb - install SSL session resumption database

SYNOPSIS

#include <cat/cat.h>

int catssl_setdb(catssl_info *info, catdb_func *func, void *handle);

DESCRIPTION

This function registers the database handler function func, used to manage the session resumption database for the SSL context defined by info. If no database handler function has been registered or if the func argument is NULL, session resumption will not be used. The handle argument can contain arbitrary data that will be passed to the function.

This function should match the following prototype:

  typedef int catdb_func(int op,
                         const catdb_data *data,
                         void *handle);

The data argument is a structure that should look as follows:

  typedef struct catdb_data {
      cat_data key;
      cat_data value;
  } catdb_data;

where cat_data is the following structure:

  typedef struct cat_data {
      int len;
      void *data;
  } cat_data;

What the function is expected to do depends on the op argument. If successful, it should return 0. Any other return value is considered a fatal error.

The op argument should be one of the following values:

CATDB_PUT
Store the data indexed by key, overwriting any existing entry. Both the key and data must be copied, and should be considered read-only.

CATDB_GET
Find the data entry indexed by key, allocate space for the value part, copy the data into the space allocated, and set the length field accordingly. The function returns 0 if successful, or any other value on error.

CATDB_DEL
Remove the entry indexed by key from the database.

CATDB_CHECK
Check if data entry indexed by key exists in the database. Return the length of the data if found.

If the length of the supplied data is greater than zero, it is compared with the data stored under key in the database. If the data does not match, CAT_EBUSY is returned.

The function is responsible for handling the ageing of old entries. In a threaded environment, the library will ensure that calls to these functions are serialized.

Returns CAT_OK.

NOTES

The SDK contains two implementations suitable as session resumption caches. The file db (only on UNIX) and the memory db interfaces.

SEE ALSO

cat, catssl, cat_memdbfunc, cat_filedbfunc