diff options
author | xuraoqing <xuraoqing@huawei.com> | 2023-03-20 14:18:19 +0800 |
---|---|---|
committer | xuraoqing <xuraoqing@huawei.com> | 2023-03-20 14:18:19 +0800 |
commit | 89ad134c3eae2627c2281174ff894fd64df51092 (patch) | |
tree | 540c5bbc16b9de213c49af1597041e26955eae89 | |
parent | 5005e0825a0dba81ed94bc262e11cc67b1d50beb (diff) | |
download | gnutls-89ad134c3eae2627c2281174ff894fd64df51092.tar.gz |
add get dn by oid test
Signed-off-by: xuraoqing <xuraoqing@huawei.com>
-rw-r--r-- | tests/crl_apis.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/crl_apis.c b/tests/crl_apis.c index d22ed3ca00..1282e72a3f 100644 --- a/tests/crl_apis.c +++ b/tests/crl_apis.c @@ -261,6 +261,32 @@ static void verify_issuer(gnutls_x509_crl_t crl, gnutls_x509_crt_deinit(crt); } +static void get_dn_by_oid(gnutls_x509_crl_t crl, + const gnutls_datum_t * issuer_cert) +{ + gnutls_x509_crt_t crt; + assert(gnutls_x509_crt_init(&crt) >= 0); + assert(gnutls_x509_crt_import(crt, issuer_cert, GNUTLS_X509_FMT_PEM) >= + 0); + + char *crt_buf = gnutls_calloc(DN_MAX_LEN, sizeof(char)); + size_t crt_buf_size = DN_MAX_LEN; + gnutls_x509_crt_get_issuer_dn_by_oid(crt, "2.5.4.3", 0, 0, crt_buf, + &crt_buf_size); + + char *crl_buf = gnutls_calloc(DN_MAX_LEN, sizeof(char)); + size_t crl_buf_size = DN_MAX_LEN; + gnutls_x509_crl_get_issuer_dn_by_oid(crl, "2.5.4.3", 0, 0, crl_buf, + &crl_buf_size); + + assert(crt_buf_size == crl_buf_size + && memcmp(crt_buf, crl_buf, crl_buf_size) == 0); + + gnutls_free(crt_buf); + gnutls_free(crl_buf); + gnutls_x509_crt_deinit(crt); +} + void doit(void) { gnutls_datum_t out; @@ -293,6 +319,9 @@ void doit(void) /* verify issuer */ verify_issuer(crl, &ca3_cert); + /* get dn by oid */ + get_dn_by_oid(crl, &ca3_cert); + gnutls_free(out.data); gnutls_x509_crl_deinit(crl); |