comparison common/certhelp.h @ 259:20d515604daa

Added new module with helper functions to parse certs. Currently only stuff to get O and CN from Subject DN.
author Sascha Wilde <wilde@intevation.de>
date Tue, 01 Apr 2014 15:41:11 +0200
parents
children 2207e94a0cc3
comparison
equal deleted inserted replaced
258:bf8c74992724 259:20d515604daa
1 #ifndef CERTHELP_H
2 #define CERTHELP_H
3
4 /* Polarssl mh.h contains a conversion which gcc warns about */
5 #pragma GCC diagnostic ignored "-Wsign-conversion"
6 #pragma GCC diagnostic ignored "-Wconversion"
7 #include <polarssl/oid.h>
8 #include <polarssl/x509_crt.h>
9 #pragma GCC diagnostic pop
10 #pragma GCC diagnostic pop
11
12 #define CERT_OID_CN (unsigned char *)OID_AT_CN "\0"
13 #define CERT_OID_O (unsigned char *)OID_AT_ORGANIZATION "\0"
14
15 /**
16 * @file
17 * @brief Helper functinos to handle and parse X.509 certificates.
18 *
19 * Simple helper functions based on PolarSSL.
20 */
21
22 /**
23 * @brief Extracts value of an gieb OID from an x509_name object.
24 *
25 * The value is copyed to an bull byte terminated c-string.
26 * The caller should free it after use.
27 * @param[in] namebuf ponter to the x509_name object.
28 * @param[in] oid the oid to search for.
29 * @returns the extracted String, or NULL in failure.
30 */
31 char *get_oid_valstr(x509_name *namebuf, unsigned char *oid);
32
33 /**
34 * @brief Parse x509 certificate and retrieve specified OID from Subject.
35 *
36 * The value is copyed to an bull byte terminated c-string.
37 * The caller should free it after use.
38 * @param[in] derdata pointer to certificate in DER format.
39 * @param[in] derlen length of the DER data.
40 * @param[in] oid the OID to search for.
41 * @returns the extracted String, or NULL in failure.
42 */
43 char *x509_parse_subject(unsigned char *derdata, size_t derlen,
44 unsigned char *oid);
45
46 #endif

http://wald.intevation.org/projects/trustbridge/