Update CRL functions and tools

This commit is contained in:
Zhi Guan
2023-01-25 22:39:12 +08:00
parent c6ca4dd37b
commit c4c11ffe6b
21 changed files with 1854 additions and 527 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2014-2022 The GmSSL Project. All Rights Reserved.
* Copyright 2014-2023 The GmSSL Project. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the License); you may
* not use this file except in compliance with the License.
@@ -12,6 +12,7 @@
#include <string.h>
#include <stdlib.h>
#include <gmssl/http.h>
#include <gmssl/x509_crl.h>
#include <gmssl/error.h>
@@ -77,17 +78,33 @@ static int test_http_parse_uri_bad(void)
return 1;
}
static int test_http_get_crl(void)
{
char *tests[] = {
"http://crl.pki.goog/gsr1/gsr1.crl",
};
uint8_t buf[65536];
size_t contentlen;
size_t i;
for (i = 0; i < sizeof(tests)/sizeof(tests[0]); i++) {
if (http_get(tests[i], buf, &contentlen, sizeof(buf)) != 1) {
fprintf(stderr, "%s() tests[%zu] <%s> failure\n", __FUNCTION__, i, tests[i]);
error_print();
return -1;
}
x509_crl_print(stderr, 0, 0, "CRL", buf, contentlen);
}
printf("%s() ok\n", __FUNCTION__);
return 1;
}
int main(void)
{
if (test_http_parse_uri() != 1) { error_print(); return -1; }
if (test_http_parse_uri_bad() != 1) { error_print(); return -1; }
if (test_http_get_crl() != 1) { error_print(); return -1; }
printf("%s all tests passed\n", __FILE__);
return 0;
}