Mercurial > trustbridge
annotate common/certhelp.c @ 400:d481b1d0956f
Resized the administrator main window.
author | Raimund Renkert <rrenkert@intevation.de> |
---|---|
date | Wed, 16 Apr 2014 10:08:32 +0200 |
parents | 81a205fc651e |
children | 17e1c8f37d72 |
rev | line source |
---|---|
259
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
1 #include <stdlib.h> |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
2 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
3 #include "certhelp.h" |
260 | 4 #include "logging.h" |
259
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
5 #include "errorcodes.h" |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
6 #include "strhelp.h" |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
7 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
8 char * |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
9 get_oid_valstr(x509_name *namebuf, unsigned char *oid) |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
10 { |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
11 char *str = NULL; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
12 size_t oid_len = strlen((char *)oid); |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
13 while ( namebuf != NULL ) |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
14 { |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
15 if ( (namebuf->oid.len == oid_len) && |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
16 (memcmp(namebuf->oid.p, oid, oid_len) == 0) ) |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
17 { |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
18 str = xstrndup((char *)namebuf->val.p, namebuf->val.len); |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
19 break; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
20 } |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
21 namebuf = namebuf->next; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
22 } |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
23 return str; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
24 } |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
25 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
26 char * |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
27 x509_parse_subject(unsigned char *derdata, size_t derlen, |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
28 unsigned char *oid) |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
29 { |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
30 x509_crt chain; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
31 char *str; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
32 |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
33 x509_crt_init(&chain); |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
34 if (x509_crt_parse_der(&chain, derdata, derlen) != 0) |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
35 { |
332
81a205fc651e
Do not exit on error
Andre Heinecke <aheinecke@intevation.de>
parents:
260
diff
changeset
|
36 ERRORPRINTF("Could not parse certificate!\n"); |
81a205fc651e
Do not exit on error
Andre Heinecke <aheinecke@intevation.de>
parents:
260
diff
changeset
|
37 return NULL; |
259
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
38 } |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
39 else |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
40 { |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
41 str = get_oid_valstr(&(chain.subject), oid); |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
42 x509_crt_free(&chain); |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
43 } |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
44 return str; |
20d515604daa
Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff
changeset
|
45 } |