source: creddy/verify.c @ 08bb122

abac0-leakabac0-meicompt_changesgec13mei-idmei-rt0-nmei_rt0tvf-new-xml 0.2.0
Last change on this file since 08bb122 was 08bb122, checked in by Mike Ryan <mikeryan@…>, 12 years ago

error code is 0 on success
fixes #22

  • Property mode set to 100644
File size: 1.2 KB
Line 
1#include <creddy.h>
2
3#include "creddy_common.h"
4
5// ugh, this needs to go away
6// do so by replacing this with a call into libabac
7#include "libcreddy_common.h"
8
9void verify_main(options_t *opts) {
10    certificate_t *subject_cert = NULL;
11
12    if (opts->cert == NULL)
13        usage(opts);
14
15    creddy_id_t *issuer = creddy_id_from_file(opts->cert);
16    if (issuer == NULL)
17        errx(1, "Can't load issuer cert from %s", opts->cert);
18    certificate_t *cert = creddy_id_cert(issuer); // replace this with a call into libabac
19
20    if (opts->attrcert != NULL)
21        subject_cert = attr_cert_from_file(opts->attrcert);
22    else
23        subject_cert = cert;
24
25    int good = 0;
26    if (subject_cert->issued_by(subject_cert, cert))
27        if (subject_cert->get_validity(subject_cert, NULL, NULL, NULL))
28            if (cert->get_validity(cert, NULL, NULL, NULL)) {
29                puts("signature good, certificates valid");
30                good = 1;
31            }
32            else
33                puts("signature good, issuer cert not valid now");
34        else
35            puts("certificate not valid now");
36    else
37        puts("signature invalid");
38
39    if (subject_cert != cert)
40        DESTROY_IF(subject_cert);
41    creddy_id_free(issuer);
42
43    exit(good ? 0 : 1);
44}
Note: See TracBrowser for help on using the repository browser.