mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 10:47:28 +02:00
Should not be an error to call wolfSSL_X509_REQ_add_extensions with empty stack.
This commit is contained in:
10
src/x509.c
10
src/x509.c
@ -13616,13 +13616,21 @@ static int regenX509REQDerBuffer(WOLFSSL_X509* x509)
|
|||||||
int wolfSSL_X509_REQ_add_extensions(WOLFSSL_X509* req,
|
int wolfSSL_X509_REQ_add_extensions(WOLFSSL_X509* req,
|
||||||
WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* ext_sk)
|
WOLF_STACK_OF(WOLFSSL_X509_EXTENSION)* ext_sk)
|
||||||
{
|
{
|
||||||
|
WOLFSSL_X509_EXTENSION* ext = NULL;
|
||||||
|
|
||||||
if (!req || !ext_sk) {
|
if (!req || !ext_sk) {
|
||||||
WOLFSSL_MSG("Bad parameter");
|
WOLFSSL_MSG("Bad parameter");
|
||||||
return WOLFSSL_FAILURE;
|
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) {
|
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) {
|
if (wolfSSL_X509_add_ext(req, ext, -1) != WOLFSSL_SUCCESS) {
|
||||||
WOLFSSL_MSG("wolfSSL_X509_add_ext error");
|
WOLFSSL_MSG("wolfSSL_X509_add_ext error");
|
||||||
|
@ -43377,6 +43377,8 @@ static int test_othername_and_SID_ext(void) {
|
|||||||
AssertNotNull(sid_ext = X509_EXTENSION_create_by_OBJ(NULL, sid_oid, 0,
|
AssertNotNull(sid_ext = X509_EXTENSION_create_by_OBJ(NULL, sid_oid, 0,
|
||||||
sid_data));
|
sid_data));
|
||||||
AssertNotNull(exts = sk_X509_EXTENSION_new_null());
|
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, san_ext), 1);
|
||||||
AssertIntEQ(sk_X509_EXTENSION_push(exts, sid_ext), 2);
|
AssertIntEQ(sk_X509_EXTENSION_push(exts, sid_ext), 2);
|
||||||
AssertIntEQ(X509_REQ_add_extensions(x509, exts), 1);
|
AssertIntEQ(X509_REQ_add_extensions(x509, exts), 1);
|
||||||
|
Reference in New Issue
Block a user