2
0

x509_dup_cert_test.c 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright 2017-2020 The OpenSSL Project Authors. All Rights Reserved.
  3. * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
  4. *
  5. * Licensed under the Apache License 2.0 (the "License"). You may not use
  6. * this file except in compliance with the License. You can obtain a copy
  7. * in the file LICENSE in the source distribution or at
  8. * https://www.openssl.org/source/license.html
  9. */
  10. #include <stdio.h>
  11. #include <openssl/err.h>
  12. #include <openssl/x509_vfy.h>
  13. #include "testutil.h"
  14. static int test_509_dup_cert(int n)
  15. {
  16. int ret = 0;
  17. X509_STORE *store = NULL;
  18. X509_LOOKUP *lookup = NULL;
  19. const char *cert_f = test_get_argument(n);
  20. if (TEST_ptr(store = X509_STORE_new())
  21. && TEST_ptr(lookup = X509_STORE_add_lookup(store, X509_LOOKUP_file()))
  22. && TEST_true(X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM))
  23. && TEST_true(X509_load_cert_file(lookup, cert_f, X509_FILETYPE_PEM)))
  24. ret = 1;
  25. X509_STORE_free(store);
  26. return ret;
  27. }
  28. OPT_TEST_DECLARE_USAGE("cert.pem...\n")
  29. int setup_tests(void)
  30. {
  31. size_t n;
  32. if (!test_skip_common_options()) {
  33. TEST_error("Error parsing test options\n");
  34. return 0;
  35. }
  36. n = test_get_argument_count();
  37. if (!TEST_int_gt(n, 0))
  38. return 0;
  39. ADD_ALL_TESTS(test_509_dup_cert, n);
  40. return 1;
  41. }