]>
git.ipfire.org Git - thirdparty/hostap.git/blob - tests/test-x509v3.c
2 * Testing tool for X.509v3 routines
3 * Copyright (c) 2006-2007, Jouni Malinen <j@w1.fi>
5 * This software may be distributed under the terms of the BSD license.
6 * See README for more details.
13 #include "tls/x509v3.h"
15 extern int wpa_debug_level
;
18 int main(int argc
, char *argv
[])
22 struct x509_certificate
*certs
= NULL
, *last
= NULL
, *cert
;
27 if (argc
< 3 || strcmp(argv
[1], "-v") != 0) {
28 printf("usage: test_x509v3 -v <cert1.der> <cert2.der> ..\n");
32 for (i
= 2; i
< argc
; i
++) {
33 printf("Reading: %s\n", argv
[i
]);
34 buf
= os_readfile(argv
[i
], &len
);
36 printf("Failed to read '%s'\n", argv
[i
]);
40 cert
= x509_certificate_parse((u8
*) buf
, len
);
42 printf("Failed to parse X.509 certificate\n");
55 printf("\n\nValidating certificate chain\n");
56 if (x509_certificate_chain_validate(last
, certs
, &reason
, 0) < 0) {
57 printf("\nCertificate chain validation failed: %d\n", reason
);
60 printf("\nCertificate chain is valid\n");