2
* Testing tool for X.509v3 routines
3
* Copyright (c) 2006, Jouni Malinen <j@w1.fi>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License version 2 as
7
* published by the Free Software Foundation.
9
* Alternatively, this software may be distributed under the terms of BSD
12
* See README and COPYING for more details.
21
extern int wpa_debug_level;
24
int main(int argc, char *argv[])
28
struct x509_certificate *certs = NULL, *last = NULL, *cert;
33
if (argc < 3 || strcmp(argv[1], "-v") != 0) {
34
printf("usage: test_x509v3 -v <cert1.der> <cert2.der> ..\n");
38
for (i = 2; i < argc; i++) {
39
printf("Reading: %s\n", argv[i]);
40
buf = os_readfile(argv[i], &len);
42
printf("Failed to read '%s'\n", argv[i]);
46
cert = x509_certificate_parse(buf, len);
48
printf("Failed to parse X.509 certificate\n");
61
printf("\n\nValidating certificate chain\n");
62
if (x509_certificate_chain_validate(last, certs, &reason) < 0) {
63
printf("\nCertificate chain validation failed: %d\n", reason);
66
printf("\nCertificate chain is valid\n");