typedef int (*CertMapInitFn_t)(void *certmap_info,
const char *issuerName, const char *issuerDN,
const char *libname);
LDAPU_SUCCESS
.certmap.conf
file, you can specify an initialization function.
As is the case with the other functions, you need to define your initialization function in your shared library (or dynamic link library). To specify the library of your functions that needs to be loaded, use the Library
statement in the certmap.conf
file.
certmap ace ou=Ace Certificate Authority, o=Ace Industry, c=US
ace:library /usr/netscape/suitespot/userdb/mylib.so
ace:InitFn plugin_init_fn
ace:DNComps ou, o, c
ace:FilterComps uid, mail
ace:verifycert onWhen the configuration file is loaded, any user-defined initialization functions are called with the
certmap_info
structure pertaining to the certificate authority (CA).my_mapping_fn()
and the verification function my_v_fn()
should be used instead of the default mapping and verification functions. Since this section of code does not set up a search function, the default search function is used.
#include <stdio.h>
#include "certmap.h"
/* init function must be defined extern "C" if using a C++ compiler */
#ifdef __cplusplus
extern "C" {
#endif
int my_init_fn (void *certmap_info, const char *issuerName,
const char *issuerDN, const char *libname);
#ifdef __cplusplus
}
#endif
int my_init_fn (void *certmap_info, const char *issuerName,
const char *issuerDN, const char *libname)
{
int rv;
static int initialized = 0;
/* Make sure CertmapDLLInit is initialized only once */
if (!initialized) {
#ifdef WIN32
CertmapDLLInit(rv, libname);
if (rv != LDAPU_SUCCESS) {
/* If you want to log an error, insert the code here. */
return rv;
}
#endif
initialized = 1;
}
/* Specify that the function my_mapping_fn() should be used to generate base DNs and search filters, rather than the default function */
rv = ldapu_set_cert_mapfn(issuerDN, (CertMapFn_t)my_mapping_fn);
if ( rv != LDAPU_SUCCESS ) {
return LDAPU_CERT_MAP_INITFN_FAILED;
}
/* Specify that the function my_v_fn() should be used to verify certificates, rather than the default function */
rv = ldapu_set_cert_verifyfn(issuerDN, (CertVerifyFn_t)my_v_fn);
if (rv != LDAPU_SUCCESS ) {
return LDAPU_CERT_MAP_INITFN_FAILED;
}
return LDAPU_SUCCESS;
}