http_crltest.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the License); you may
  5. * not use this file except in compliance with the License.
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. */
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <stdlib.h>
  12. #include <gmssl/oid.h>
  13. #include <gmssl/x509_alg.h>
  14. #include <gmssl/x509_crl.h>
  15. #include <gmssl/x509_ext.h>
  16. #include <gmssl/x509.h>
  17. #include <gmssl/rand.h>
  18. #include <gmssl/error.h>
  19. static int test_x509_crl_new_from_uri(void)
  20. {
  21. char *tests[] = {
  22. "http://crl.microsoft.com/pki/mscorp/crl/Microsoft%20RSA%20TLS%20CA%2002.crl", // from bing.com entity-cert
  23. "http://crl3.digicert.com/Omniroot2025.crl", // from bing.com mid-CA cert
  24. "http://crl.globalsign.com/gsrsaovsslca2018.crl", // from baidu.com entity cert
  25. "http://crl.globalsign.com/root-r3.crl", // from baidu.com mid-CA cert
  26. "http://crl.globalsign.com/gs/gsorganizationvalsha2g2.crl", // from taobao.com entity cert
  27. };
  28. size_t i;
  29. uint8_t *crl = NULL;
  30. size_t crl_len;
  31. for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
  32. if (x509_crl_new_from_uri(&crl, &crl_len, tests[i], strlen(tests[i])) != 1) {
  33. error_print();
  34. fprintf(stderr, "test %zu: %s\n", i, tests[i]);
  35. return -1;
  36. }
  37. x509_crl_print(stderr, 0, 0, "CRL", crl, crl_len);
  38. fprintf(stderr, "\n\n");
  39. free(crl);
  40. crl = NULL;
  41. }
  42. return 1;
  43. }
  44. int main(void)
  45. {
  46. if (test_x509_crl_new_from_uri() != 1) { error_print(); return -1; }
  47. printf("%s all tests passed\n", __FILE__);
  48. return 0;
  49. }