extcmap.h 26 KB

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