]>
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"
16 int main(int argc
, char *argv
[])
20 struct x509_certificate
*certs
= NULL
, *last
= NULL
, *cert
;
25 if (argc
< 3 || strcmp(argv
[1], "-v") != 0) {
26 printf("usage: test_x509v3 -v <cert1.der> <cert2.der> ..\n");
30 for (i
= 2; i
< argc
; i
++) {
31 printf("Reading: %s\n", argv
[i
]);
32 buf
= os_readfile(argv
[i
], &len
);
34 printf("Failed to read '%s'\n", argv
[i
]);
38 cert
= x509_certificate_parse((u8
*) buf
, len
);
40 printf("Failed to parse X.509 certificate\n");
53 printf("\n\nValidating certificate chain\n");
54 if (x509_certificate_chain_validate(last
, certs
, &reason
, 0) < 0) {
55 printf("\nCertificate chain validation failed: %d\n", reason
);
58 printf("\nCertificate chain is valid\n");