extcmap.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. * END COPYRIGHT BLOCK **/
  6. #ifndef _PUBLIC_CERTMAP_H
  7. #define _PUBLIC_CERTMAP_H
  8. #include <ldap.h>
  9. #ifndef NSAPI_PUBLIC
  10. #if defined( _WINDOWS ) || defined( _WIN32 ) || defined( XP_WIN32 )
  11. #define NSAPI_PUBLIC __declspec(dllexport)
  12. #else
  13. #define NSAPI_PUBLIC
  14. #endif
  15. #endif
  16. #define LDAPU_ATTR_INITFN "InitFn"
  17. #define LDAPU_ATTR_LIBRARY "library"
  18. #define LDAPU_ATTR_DNCOMPS "DNComps"
  19. #define LDAPU_ATTR_FILTERCOMPS "FilterComps"
  20. #define LDAPU_ATTR_VERIFYCERT "VerifyCert"
  21. #define LDAPU_ATTR_CERTMAP_LDAP_ATTR "CmapLdapAttr"
  22. /* Error/Success codes */
  23. #define LDAPU_SUCCESS 0
  24. #define LDAPU_FAILED -1
  25. #define LDAPU_CERT_MAP_FUNCTION_FAILED -2
  26. #define LDAPU_CERT_SEARCH_FUNCTION_FAILED -3
  27. #define LDAPU_CERT_VERIFY_FUNCTION_FAILED -4
  28. #define LDAPU_CERT_MAP_INITFN_FAILED -5
  29. /*
  30. * CertMapFn_t -
  31. * This is a typedef for cert mapping function. The mapping function is
  32. * called by the function ldapu_cert_to_ldap_entry.
  33. * Parameters:
  34. * cert - cert to be mapped. You can pass this to
  35. * functions ldapu_get_cert_XYZ.
  36. * ld - Handle to the connection to the directory server.
  37. * certmap_info - This structure contains information about the
  38. * configuration parameters for the cert's issuer (CA).
  39. * This structure can be passed to the function
  40. * ldapu_certmap_info_attrval to get value for a particular
  41. * configuration attribute (or a property).
  42. * ldapdn - The mapping function should allocate memory for ldapdn
  43. * using malloc and set this variable using the 'cert' and
  44. * 'certmap_info'. This DN will be used for ldap lookup.
  45. * filter - The mapping function should allocate memory for filter
  46. * using malloc and set this variable using the 'cert' and
  47. * 'certmap_info'. This will be used as ldap filter for ldap
  48. * lookup of the ldapdn.
  49. *
  50. * Return Value:
  51. * return LDAPU_SUCCESS upon successful completion (cert is mapped)
  52. * return LDAPU_FAILED there is no unexpected error but cert could not
  53. * mapped (probably because ldap entry doesn't exist).
  54. * otherwise return LDAPU_CERT_MAP_FUNCTION_FAILED.
  55. */
  56. typedef int (*CertMapFn_t)(void *cert, LDAP *ld, void *certmap_info,
  57. char **ldapdn, char **filter);
  58. /*
  59. * CertSearchFn_t -
  60. * This is a typedef for cert search function. The search function is
  61. * called by the function ldapu_cert_to_ldap_entry after calling the mapping
  62. * function. The candidate 'dn' and 'filter' returned by the mapping
  63. * function is passed to this function.
  64. * The default search function works as follows:
  65. * 1. If the 'filter' is NULL, default it to 'objectclass=*'.
  66. * 2. If the 'dn' is non-NULL, do a base level search with the 'dn' and
  67. * 'filter'. If it succeeds, we are done. If there is no serious
  68. * error (LDAP_NO_SUCH_OBJECT is not serious error yet), continue.
  69. * 3. If the 'dn' is NULL, default it to 'basedn'.
  70. * 4. Perform a 'subtree' search in LDAP for the 'dn' and the 'filter'.
  71. * 5. Return the results of the last search.
  72. * Parameters:
  73. * cert - cert to be mapped. You can pass this to
  74. * functions ldapu_get_cert_XYZ.
  75. * ld - Handle to the connection to the directory server.
  76. * certmap_info - This structure contains information about the
  77. * configuration parameters for the cert's issuer (CA).
  78. * This structure can be passed to the function
  79. * ldapu_certmap_info_attrval to get value for a particular
  80. * configuration attribute (or a property).
  81. * suffix - If the ldapdn is empty then use this DN to begin the
  82. * search. This is the DN of the root object in LDAP
  83. * Directory.
  84. * ldapdn - candidate 'dn' returned by the mapping function.
  85. * filter - returned by the mapping function.
  86. * attrs - list of attributes to return from the search. If this is
  87. * NULL, all attributes are returned.
  88. * res - result of the search which is passed to the verify
  89. * function.
  90. *
  91. * Return Value:
  92. * return LDAPU_SUCCESS upon successful completion
  93. * return LDAPU_FAILED there is no unexpected error but entries matching the
  94. * 'dn' and 'filter' doesn't exist.
  95. * otherwise return LDAPU_CERT_SEARCH_FUNCTION_FAILED.
  96. */
  97. typedef int (*CertSearchFn_t)(void *cert, LDAP *ld, void *certmap_info,
  98. const char *suffix, const char *ldapdn,
  99. const char *filter, const char **attrs,
  100. LDAPMessage ***res);
  101. /*
  102. * CertVerifyFn_t -
  103. * This is a typedef for cert verify function. The verify function is
  104. * called by the function ldapu_cert_to_ldap_entry after the cert is
  105. * successfully mapped to ldapdn and filter, and an entry matching that
  106. * exists in the directory server. The verify fn may get called for
  107. * multiple matched entries. This function must go through all the entries
  108. * and check which one is appropriate. The pointer to that entry must be
  109. * passed back in the 'LDAPMessage **entry' parameter.
  110. * Parameters:
  111. * cert - Original cert to be mapped. You can pass this to
  112. * functions ldapu_get_cert_XYZ.
  113. * ld - Handle to the connection to the directory server.
  114. * certmap_info - This structure contains information about the
  115. * configuration parameters for the cert's issuer (CA).
  116. * This structure can be passed to the function
  117. * ldapu_certmap_info_attrval to get value for a particular
  118. * configuration attribute (or a property).
  119. * res - cert is first mapped to ldapdn and filter. 'res' is the
  120. * result of ldap search using the ldapdn and filter.
  121. * 'ld' and 'res' can be used in the calls to ldapsdk API.
  122. * entry - pointer to the entry from 'res' which is the correct match
  123. * according to the verify function.
  124. *
  125. * Return Values:
  126. * return LDAPU_SUCCESS upon successful completion (cert is verified)
  127. * return LDAPU_FAILED there is no unexpected error but cert could not
  128. * verified (probably because it was revoked).
  129. * otherwise return LDAPU_CERT_VERIFY_FUNCTION_FAILED.
  130. */
  131. typedef int (*CertVerifyFn_t)(void *cert, LDAP *ld, void *certmap_info,
  132. LDAPMessage *res, LDAPMessage **entry);
  133. /*
  134. * CertmapInitFn_t -
  135. * This is a typedef for user defined init function. An init function can be
  136. * specified in the config file (<ServerRoot>/userdb/certmap.conf) per issuer
  137. * of a certificate. This init function must from the user's library, also
  138. * loaded from the config file using the 'library' property. The init
  139. * function is specified in the config file using the 'InitFn' property.
  140. * When the config file is loaded, any user defined init functions will be
  141. * called with the certmap_info pertaining to the issuer (CA).
  142. * Parameters:
  143. * certmap_info - This structure contains information about the
  144. * configuration parameters for the cert's issuer (CA).
  145. * This structure can be passed to the function
  146. * ldapu_certmap_info_attrval to get value for a particular
  147. * configuration attribute (or a property).
  148. *
  149. * Return Value:
  150. * return LDAPU_SUCCESS upon successful completion
  151. * otherwise return LDAPU_CERT_MAP_INITFN_FAILED. The server startup will be
  152. * aborted if the return value is not LDAPU_SUCCESS.
  153. */
  154. typedef int (*CertMapInitFn_t)(void *certmap_info, const char *issuerName,
  155. const char *issuerDN, const char *libname);
  156. /*
  157. * Refer to the description of the function ldapu_get_cert_ava_val
  158. */
  159. enum {
  160. LDAPU_SUBJECT_DN,
  161. LDAPU_ISSUER_DN
  162. };
  163. /* ldapu_cert_to_ldap_entry */
  164. typedef int (*t_ldapu_cert_to_ldap_entry)(void *cert, LDAP *ld,
  165. const char *suffix,
  166. LDAPMessage **res);
  167. /* ldapu_set_cert_mapfn */
  168. typedef int (*t_ldapu_set_cert_mapfn)(const char *issuerDN,
  169. CertMapFn_t mapfn);
  170. /* ldapu_get_cert_mapfn */
  171. typedef CertMapFn_t (*t_ldapu_get_cert_mapfn) (const char *issuerDN);
  172. /* ldapu_set_cert_searchfn */
  173. typedef int (*t_ldapu_set_cert_searchfn) (const char *issuerDN,
  174. CertSearchFn_t searchfn);
  175. /* ldapu_get_cert_searchfn */
  176. typedef CertSearchFn_t (*t_ldapu_get_cert_searchfn) (const char *issuerDN);
  177. /* ldapu_set_cert_verifyfn */
  178. typedef int (*t_ldapu_set_cert_verifyfn) (const char *issuerDN,
  179. CertVerifyFn_t verifyFn);
  180. /* ldapu_get_cert_verifyfn */
  181. typedef CertVerifyFn_t (*t_ldapu_get_cert_verifyfn) (const char *issuerDN);
  182. /* ldapu_get_cert_subject_dn */
  183. typedef int (*t_ldapu_get_cert_subject_dn) (void *cert, char **subjectDN);
  184. /* ldapu_get_cert_issuer_dn */
  185. typedef int (*t_ldapu_get_cert_issuer_dn) (void *cert, char **issuerDN);
  186. /* ldapu_get_cert_ava_val */
  187. typedef int (*t_ldapu_get_cert_ava_val) (void *cert, int which_dn,
  188. const char *attr, char ***val);
  189. /* ldapu_free_cert_ava_val */
  190. typedef int (*t_ldapu_free_cert_ava_val) (char **val);
  191. /* ldapu_get_cert_der */
  192. typedef int (*t_ldapu_get_cert_der) (void *cert, unsigned char **derCert,
  193. unsigned int *len);
  194. /* ldapu_issuer_certinfo */
  195. typedef int (*t_ldapu_issuer_certinfo) (const char *issuerDN,
  196. void **certmap_info);
  197. /* ldapu_certmap_info_attrval */
  198. typedef int (*t_ldapu_certmap_info_attrval) (void *certmap_info,
  199. const char *attr, char **val);
  200. /* ldapu_err2string */
  201. typedef char * (*t_ldapu_err2string) (int err);
  202. /* ldapu_free */
  203. typedef void (*t_ldapu_free_old) (char *ptr);
  204. typedef void (*t_ldapu_free) (void *ptr);
  205. /* ldapu_malloc */
  206. typedef void *(*t_ldapu_malloc) (int size);
  207. /* ldapu_strdup */
  208. typedef char *(*t_ldapu_strdup) (const char *ptr);
  209. typedef struct LDAPUDispatchVector LDAPUDispatchVector_t;
  210. struct LDAPUDispatchVector {
  211. t_ldapu_cert_to_ldap_entry f_ldapu_cert_to_ldap_entry;
  212. t_ldapu_set_cert_mapfn f_ldapu_set_cert_mapfn;
  213. t_ldapu_get_cert_mapfn f_ldapu_get_cert_mapfn;
  214. t_ldapu_set_cert_searchfn f_ldapu_set_cert_searchfn;
  215. t_ldapu_get_cert_searchfn f_ldapu_get_cert_searchfn;
  216. t_ldapu_set_cert_verifyfn f_ldapu_set_cert_verifyfn;
  217. t_ldapu_get_cert_verifyfn f_ldapu_get_cert_verifyfn;
  218. t_ldapu_get_cert_subject_dn f_ldapu_get_cert_subject_dn;
  219. t_ldapu_get_cert_issuer_dn f_ldapu_get_cert_issuer_dn;
  220. t_ldapu_get_cert_ava_val f_ldapu_get_cert_ava_val;
  221. t_ldapu_free_cert_ava_val f_ldapu_free_cert_ava_val;
  222. t_ldapu_get_cert_der f_ldapu_get_cert_der;
  223. t_ldapu_issuer_certinfo f_ldapu_issuer_certinfo;
  224. t_ldapu_certmap_info_attrval f_ldapu_certmap_info_attrval;
  225. t_ldapu_err2string f_ldapu_err2string;
  226. t_ldapu_free_old f_ldapu_free_old;
  227. t_ldapu_malloc f_ldapu_malloc;
  228. t_ldapu_strdup f_ldapu_strdup;
  229. t_ldapu_free f_ldapu_free;
  230. };
  231. #ifdef INTLDAPU
  232. NSAPI_PUBLIC extern LDAPUDispatchVector_t *__ldapu_table;
  233. #else
  234. typedef int (*CertMapDLLInitFn_t)(LDAPUDispatchVector_t **table);
  235. NSAPI_PUBLIC extern int CertMapDLLInitFn(LDAPUDispatchVector_t **table);
  236. extern LDAPUDispatchVector_t *__ldapu_table;
  237. #if defined( _WINDOWS ) || defined( _WIN32 ) || defined( XP_WIN32 )
  238. #define CertmapDLLInitFnTbl LDAPUDispatchVector_t *__ldapu_table;
  239. #define CertmapDLLInit(rv, libname) \
  240. {\
  241. HANDLE h = LoadLibrary((libname)); \
  242. CertMapDLLInitFn_t init_fn; \
  243. if (!h) return LDAPU_CERT_MAP_INITFN_FAILED; \
  244. init_fn = (CertMapDLLInitFn_t)GetProcAddress(h, "CertMapDLLInitFn"); \
  245. rv = init_fn(&__ldapu_table); \
  246. }
  247. #else
  248. #define CertmapDLLInit(rv, libname)
  249. #define CertmapDLLInitFnTbl
  250. #endif
  251. #endif /* INTLDAPU */
  252. #ifndef INTLDAPU
  253. /*
  254. * ldapu_cert_to_ldap_entry -
  255. * This function is called to map a cert to an ldap entry. It extracts the
  256. * cert issuer information from the given cert. The mapping function set for
  257. * the issuer (if any) or the default mapping function is called to map the
  258. * subject DN from the cert to a candidate ldap DN and filter for ldap
  259. * search. If the mapped ldap DN is NULL, the 'basedn' passed into this
  260. * function is used as a starting place for the search. If the mapped filter
  261. * is NULL, "objectclass=*" is used as a filter. A base level search is
  262. * performed to see if the candidate DN exists in the LDAP database matching
  263. * the filter. If there is no match, a scoped search (sub-tree search) is
  264. * performed. If at least one entry matched the mapped DN and filter, the
  265. * result is passed to the appropriate verify function. The verify function
  266. * is called only if 'VerifyCert' parameter has been set for the cert issuer
  267. * in the certmap.conf file.
  268. * If the verify function succeeds, it must return the pointer to the matched
  269. * 'entry'. If at the end, there is only one matching entry, the mapping is
  270. * successful.
  271. * Parameters:
  272. * cert - cert to be mapped. You can pass this to
  273. * functions ldapu_get_cert_XYZ.
  274. * ld - Handle to the connection to the directory server.
  275. * suffix - If the subject dn is mapped to empty LDAP DN then use this
  276. * DN to begin the search. This is the DN of the root object
  277. * in LDAP Directory.
  278. * res - cert is first mapped to ldapdn and filter. 'res' is the
  279. * result of ldap search using the ldapdn and filter.
  280. * 'ld' and 'res' can be used in the calls to ldapsdk API.
  281. * When done with 'res', free it using ldap_msgfree(res)
  282. *
  283. * Return Value:
  284. * return LDAPU_SUCCESS upon successful completion
  285. * otherwise returns an error code that can be passed to ldapu_err2string.
  286. */
  287. #define ldapu_cert_to_ldap_entry (*__ldapu_table->f_ldapu_cert_to_ldap_entry)
  288. /*
  289. * ldapu_set_cert_mapfn -
  290. * This function can be used to set the cert mapping function for the given
  291. * issuer (CA). If the mapping information doesn't exist for the given
  292. * issuer then a new one will be created and the mapping function will be
  293. * set. When creating the new mapping information, the default mapping
  294. * information is copied.
  295. * Parameters:
  296. * issuerDN - DN of the cert issuer. This mapping function will be used
  297. * for all certs issued by this issuer. If the issuerDN is
  298. * NULL, the given 'mapfn' becomes the default mapping
  299. * function (which is used when no mapping function has been
  300. * set for the cert's issuer).
  301. * mapfn - the mapping function. Look at the desciption of
  302. * CertMapFn_t to find out more about the mapping functions.
  303. *
  304. * Return Value:
  305. * return LDAPU_SUCCESS upon successful completion
  306. * otherwise returns an error code that can be passed to ldapu_err2string.
  307. */
  308. #define ldapu_set_cert_mapfn (*__ldapu_table->f_ldapu_set_cert_mapfn)
  309. /*
  310. * ldapu_get_cert_mapfn -
  311. * This function can be used to get the cert mapping function for the given
  312. * issuer (CA). This will always return a non-NULL function.
  313. * Parameters:
  314. * issuerDN - DN of the cert issuer for which the mapping function is to
  315. * be retrieved. If this is NULL, default mapping function
  316. * is returned.
  317. *
  318. * Return Value:
  319. * The mapping function set for the issuer is returned. If the issuerDN is
  320. * NULL or if no specific mapping function has been set for the issuer, the
  321. * default mapping function is returned.
  322. */
  323. #define ldapu_get_cert_mapfn (*__ldapu_table->f_ldapu_get_cert_mapfn)
  324. /*
  325. * ldapu_set_cert_searchfn -
  326. * This function can be used to set the cert search function for the given
  327. * issuer (CA).
  328. * Parameters:
  329. * issuerDN - DN of the cert issuer. This search function will be used
  330. * for all certs issued by this issuer. If the issuerDN is
  331. * NULL, the given 'searchfn' becomes the default search
  332. * function (which is used when no search function has been
  333. * set for the cert's issuer).
  334. * searchfn - the search function. Look at the desciption of
  335. * CertSearchFn_t to find out more about the search functions.
  336. *
  337. * Return Value:
  338. * return LDAPU_SUCCESS upon successful completion
  339. * otherwise returns an error code that can be passed to ldapu_err2string.
  340. */
  341. #define ldapu_set_cert_searchfn (*__ldapu_table->f_ldapu_set_cert_searchfn)
  342. /*
  343. * ldapu_get_cert_searchfn -
  344. * This function can be used to get the cert search function for the given
  345. * issuer (CA). This will always return a non-NULL function.
  346. * Parameters:
  347. * issuerDN - DN of the cert issuer for which the search function is to
  348. * be retrieved. If this is NULL, the default search
  349. * function is returned.
  350. *
  351. * Return Value:
  352. * The search function set for the issuer is returned. If the issuerDN is
  353. * NULL or if no specific search function has been set for the issuer, the
  354. * default search function is returned.
  355. */
  356. #define ldapu_get_cert_searchfn (*__ldapu_table->f_ldapu_get_cert_searchfn)
  357. /*
  358. * ldapu_set_cert_verifyfn -
  359. * This function can be used to set the cert verify function for the given
  360. * issuer (CA). If the mapping information doesn't exist for the given
  361. * issuer then a new one will be created and the verify function will be
  362. * set. When creating the new mapping information, the default mapping
  363. * information is copied.
  364. * Parameters:
  365. * issuerDN - DN of the cert issuer. This verify function will be used
  366. * for all certs issued by this issuer. If the issuerDN is
  367. * NULL, the given 'verifyFn' becomes the default verify
  368. * function (which is used when no verify function has been
  369. * set for the cert's issuer).
  370. * verifyFn - the verify function. Look at the desciption of
  371. * CertMapFn_t to find out more about the verify functions.
  372. *
  373. * Return Value:
  374. * return LDAPU_SUCCESS upon successful completion
  375. * otherwise returns an error code that can be passed to ldapu_err2string.
  376. */
  377. #define ldapu_set_cert_verifyfn (*__ldapu_table->f_ldapu_set_cert_verifyfn)
  378. /*
  379. * ldapu_get_cert_verifyfn -
  380. * This function can be used to get the cert verify function for the given
  381. * issuer (CA). This function can return NULL when there is no applicable
  382. * verify function.
  383. * Parameters:
  384. * issuerDN - DN of the cert issuer for which the verify function is to
  385. * be retrieved. If this is NULL, default verify function
  386. * is returned.
  387. *
  388. * Return Value:
  389. * The verify function set for the issuer is returned. If the issuerDN is
  390. * NULL or if no specific verify function has been set for the issuer, the
  391. * default verify function is returned. This function can return NULL when
  392. * there is no applicable verify function.
  393. */
  394. #define ldapu_get_cert_verifyfn (*__ldapu_table->f_ldapu_get_cert_verifyfn)
  395. /*
  396. * ldapu_get_cert_subject_dn -
  397. * This function can be used to get the subject DN from the cert. Free the
  398. * subjectDN using 'free' after you are done using it.
  399. * Parameters:
  400. * cert - cert from which the DN is to be extracted.
  401. * subjectDN - subjectDN extracted from the cert. Free it using 'free'
  402. * after it is no longer required.
  403. *
  404. * Return Value:
  405. * return LDAPU_SUCCESS upon successful completion
  406. * otherwise returns an error code that can be passed to ldapu_err2string.
  407. */
  408. #define ldapu_get_cert_subject_dn (*__ldapu_table->f_ldapu_get_cert_subject_dn)
  409. /*
  410. * ldapu_get_cert_issuer_dn -
  411. * This function can be used to get the issuer DN from the cert. Free the
  412. * issuerDN using 'free' after you are done using it.
  413. * Parameters:
  414. * cert - cert from which the DN is to be extracted.
  415. * issuerDN - issuerDN extracted from the cert. Free it using 'free'
  416. * after it is no longer required.
  417. *
  418. * Return Value:
  419. * return LDAPU_SUCCESS upon successful completion
  420. * otherwise returns an error code that can be passed to ldapu_err2string.
  421. */
  422. #define ldapu_get_cert_issuer_dn (*__ldapu_table->f_ldapu_get_cert_issuer_dn)
  423. /*
  424. * ldapu_get_cert_ava_val -
  425. * This function can be used to get value of the given attribute from either
  426. * the subject DN or the issuer DN from the cert.
  427. * Parameters:
  428. * cert - cert from which the values are to be extracted.
  429. * which_dn - Should be either LDAPU_ISSUER_DN or LDAPU_SUBJECT_DN.
  430. * attr - Should be one of "CN", "OU", "O", "C", "UID", "MAIL",
  431. * "E", "L", and "ST".
  432. * val - An array of attribute values extracted from the cert.
  433. * There could be multiple values. The last entry in the
  434. * array is NULL. You must free this array of strings after
  435. * you are done with it (using the function
  436. * ldapu_free_cert_ava_val). 'val' is initialized to NULL if
  437. * there is an error.
  438. *
  439. * Return Value:
  440. * return LDAPU_SUCCESS upon successful completion
  441. * otherwise returns an error code that can be passed to ldapu_err2string.
  442. */
  443. #define ldapu_get_cert_ava_val (*__ldapu_table->f_ldapu_get_cert_ava_val)
  444. /*
  445. * ldapu_free_cert_ava_val -
  446. * This function can be used to free the array returned by the
  447. * ldapu_get_cert_ava_val function.
  448. * Parameters:
  449. * val - An array of attribute values returned by
  450. * ldapu_get_cert_ava_val.
  451. *
  452. * Return Value:
  453. * return LDAPU_SUCCESS upon successful completion
  454. * otherwise returns an error code that can be passed to ldapu_err2string.
  455. */
  456. #define ldapu_free_cert_ava_val (*__ldapu_table->f_ldapu_free_cert_ava_val)
  457. /*
  458. * ldapu_get_cert_der -
  459. * This function can be used to get the original DER encoded cert for the
  460. * given cert.
  461. * Parameters:
  462. * cert - cert from which the original DER is to be extracted.
  463. * derCert - the original DER encoded cert
  464. * len - length of derCert
  465. *
  466. * Return Value:
  467. * return LDAPU_SUCCESS upon successful completion
  468. * otherwise returns an error code that can be passed to ldapu_err2string.
  469. */
  470. #define ldapu_get_cert_der (*__ldapu_table->f_ldapu_get_cert_der)
  471. /*
  472. * ldapu_issuer_certinfo -
  473. * This function can be used to get the handle on the internal structure for
  474. * the given issuer. This handle can be passed to ldapu_certmap_info_attrval
  475. * to get configuration attribute values for the issuer.
  476. * Parameters:
  477. * issuerDN - DN of the issuer for whom the handle on internal structure
  478. * is requested. If issuerDN is NULL, the handle to the
  479. * default configuration information is returned.
  480. * certmap_info - This structure contains information about the
  481. * configuration parameters for the cert's issuer (CA).
  482. * This structure can be passed to the function
  483. * ldapu_certmap_info_attrval to get value for a particular
  484. * configuration attribute (or a property).
  485. *
  486. * Return Value:
  487. * return LDAPU_SUCCESS upon successful completion
  488. * otherwise returns an error code that can be passed to ldapu_err2string.
  489. * CAUTION: DON'T FREE THE 'certmap_info' STRUCTURE.
  490. */
  491. #define ldapu_issuer_certinfo (*__ldapu_table->f_ldapu_issuer_certinfo)
  492. /*
  493. * ldapu_certmap_info_attrval -
  494. * This function can be used to get values for the given attribute/property
  495. * from the given certmap_info. You can get handle on the certmap_info by
  496. * calling the ldapu_issuer_certinfo function. Free the 'val' using 'free'
  497. * after it is no longer required.
  498. * Parameters:
  499. * certmap_info - This structure contains information about the
  500. * configuration parameters for the cert's issuer (CA).
  501. * attr - name of the attribute/property for which the value is to
  502. * be returned. The attribute can be one of the attributes
  503. * listed above (LDAPU_ATTR_XYZ). User defined attributes
  504. * can also be used.
  505. * val - Value of the 'attr' from the 'certmap_info'.
  506. *
  507. * Return Value:
  508. * return LDAPU_SUCCESS upon successful completion
  509. * otherwise returns an error code that can be passed to ldapu_err2string.
  510. */
  511. #define ldapu_certmap_info_attrval (*__ldapu_table->f_ldapu_certmap_info_attrval)
  512. /*
  513. * ldapu_err2string -
  514. * This function can be used to print any of the ldaputil or LDAP error
  515. * code.
  516. * Parameters:
  517. * err - error code to be converted to printable string.
  518. *
  519. * Return Value:
  520. * Printable representation of the given error code.
  521. */
  522. #define ldapu_err2string (*__ldapu_table->f_ldapu_err2string)
  523. /*
  524. * ldapu_free -
  525. * This function should be used to free the memory allocated by
  526. * ldapu_* functions if the ldapu_* function doesn't have a corresponding
  527. * 'free' function. Use this function for free'ing the memory allocated by
  528. * the following functions:
  529. * ldapu_get_cert_subject_dn
  530. * ldapu_get_cert_issuer_dn
  531. * ldapu_get_cert_der
  532. * ldapu_certmap_info_attrval
  533. * To free memory allocated by ldapu_get_cert_ava_val, use
  534. * ldapu_free_cert_ava_val. Do not free the certmap_info pointer returned by
  535. * ldapu_issuer_certinfo.
  536. * Parameters:
  537. * ptr - pointer returned by ldapu_get_cert_* functions.
  538. */
  539. #define ldapu_free (*__ldapu_table->f_ldapu_free)
  540. /*
  541. * ldapu_malloc -
  542. * This function is a cover function for the 'malloc' system call. On NT, it
  543. * is best to alloc & free the memory in the same DLL.
  544. * Parameters:
  545. * size - size of the memory to be allocated
  546. * Return Value:
  547. * same as 'malloc' -- pointer to the allocated memory or NULL on failure.
  548. */
  549. #define ldapu_malloc (*__ldapu_table->f_ldapu_malloc)
  550. /*
  551. * ldapu_strdup -
  552. * This function is a cover function for the 'strdup' system call. On NT, it
  553. * is best to alloc & free the memory in the same DLL.
  554. * Parameters:
  555. * ptr - Pointer to the string to be copied
  556. * Return Value:
  557. * same as 'strdup' -- pointer to the copied string or NULL on failure.
  558. */
  559. #define ldapu_strdup (*__ldapu_table->f_ldapu_strdup)
  560. #endif /* !INTLDAPU */
  561. #endif /* _PUBLIC_CERTMAP_H */