v3ext.c 965 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the OpenSSL license (the "License"). You may not use
  5. * this file except in compliance with the License. You can obtain a copy
  6. * in the file LICENSE in the source distribution or at
  7. * https://www.openssl.org/source/license.html
  8. */
  9. #include <stdio.h>
  10. #include <openssl/x509.h>
  11. #include <openssl/x509v3.h>
  12. #include <openssl/pem.h>
  13. #include <openssl/err.h>
  14. int main(int ac, char **av)
  15. {
  16. X509 *x = NULL;
  17. BIO *b = NULL;
  18. long pathlen;
  19. int ret = 1;
  20. if (ac != 2) {
  21. fprintf(stderr, "Usage error\n");
  22. goto end;
  23. }
  24. b = BIO_new_file(av[1], "r");
  25. if (b == NULL)
  26. goto end;
  27. x = PEM_read_bio_X509(b, NULL, NULL, NULL);
  28. if (x == NULL)
  29. goto end;
  30. pathlen = X509_get_pathlen(x);
  31. if (pathlen == 6)
  32. ret = 0;
  33. end:
  34. ERR_print_errors_fp(stderr);
  35. BIO_free(b);
  36. X509_free(x);
  37. return ret;
  38. }