test-x509.c 692 B

1234567891011121314151617181920212223242526272829303132333435363738
  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. extern int wpa_debug_level;
  12. int main(int argc, char *argv[])
  13. {
  14. FILE *f;
  15. u8 buf[3000];
  16. size_t len;
  17. struct x509_certificate *cert;
  18. wpa_debug_level = 0;
  19. f = fopen(argv[1], "rb");
  20. if (f == NULL)
  21. return -1;
  22. len = fread(buf, 1, sizeof(buf), f);
  23. fclose(f);
  24. cert = x509_certificate_parse(buf, len);
  25. if (cert == NULL)
  26. printf("Failed to parse X.509 certificate\n");
  27. x509_certificate_free(cert);
  28. return 0;
  29. }