test-x509.c 663 B

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * Testing tool for X.509v3 routines
  3. * Copyright (c) 2006-2009, Jouni Malinen <j@w1.fi>
  4. *
  5. * This software may be distributed under the terms of the BSD license.
  6. * See README for more details.
  7. */
  8. #include "includes.h"
  9. #include "common.h"
  10. #include "tls/x509v3.h"
  11. int main(int argc, char *argv[])
  12. {
  13. FILE *f;
  14. u8 buf[3000];
  15. size_t len;
  16. struct x509_certificate *cert;
  17. wpa_debug_level = 0;
  18. f = fopen(argv[1], "rb");
  19. if (f == NULL)
  20. return -1;
  21. len = fread(buf, 1, sizeof(buf), f);
  22. fclose(f);
  23. cert = x509_certificate_parse(buf, len);
  24. if (cert == NULL)
  25. printf("Failed to parse X.509 certificate\n");
  26. x509_certificate_free(cert);
  27. return 0;
  28. }