test-x509.c 911 B

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