Should not be an error to call wolfSSL_X509_REQ_add_extensions with empty stack.

This commit is contained in:
Anthony Hu
2023-04-18 12:27:54 -04:00
parent f7d7e4f30a
commit b0e90b6ffe
2 changed files with 11 additions and 1 deletions

View File

@ -13616,13 +13616,21 @@ static int regenX509REQDerBuffer(WOLFSSL_X509* x509)
int wolfSSL_X509_REQ_add_extensions(WOLFSSL_X509* req,
WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* ext_sk)
{
WOLFSSL_X509_EXTENSION* ext = NULL;
if (!req || !ext_sk) {
WOLFSSL_MSG("Bad parameter");
return WOLFSSL_FAILURE;
}
/* It is not an error if the stack is empty. */
ext = ext_sk->data.ext;
if (ext == NULL) {
return WOLFSSL_SUCCESS;
}
while (ext_sk) {
WOLFSSL_X509_EXTENSION* ext = ext_sk->data.ext;
ext = ext_sk->data.ext;
if (wolfSSL_X509_add_ext(req, ext, -1) != WOLFSSL_SUCCESS) {
WOLFSSL_MSG("wolfSSL_X509_add_ext error");

View File

@ -43377,6 +43377,8 @@ static int test_othername_and_SID_ext(void) {
AssertNotNull(sid_ext = X509_EXTENSION_create_by_OBJ(NULL, sid_oid, 0,
sid_data));
AssertNotNull(exts = sk_X509_EXTENSION_new_null());
/* Ensure an empty stack doesn't raise an error. */
AssertIntEQ(X509_REQ_add_extensions(x509, exts), 1);
AssertIntEQ(sk_X509_EXTENSION_push(exts, san_ext), 1);
AssertIntEQ(sk_X509_EXTENSION_push(exts, sid_ext), 2);
AssertIntEQ(X509_REQ_add_extensions(x509, exts), 1);