annotate common/certhelp.c @ 285:f23e0ccd5d14

Fix call to windows process. This now uses the correct parameters, emits the signals correctly as errors and waits for the process to finish instead of relying on NOASYNC which did not work for runas and also made it impossible to get the return code
author Andre Heinecke <aheinecke@intevation.de>
date Wed, 02 Apr 2014 13:45:57 +0000
parents e7a8b70021b6
children 81a205fc651e
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
Sascha Wilde <wilde@intevation.de>
parents: 259
diff changeset
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 {
20d515604daa Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
36 DEBUGPRINTF("FATAL: Could not parse certificate!");
20d515604daa Added new module with helper functions to parse certs.
Sascha Wilde <wilde@intevation.de>
parents:
diff changeset
37 exit(ERR_INVALID_CERT);
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 }

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