Skip to content

Commit 6f0bcac

Browse files
ColtonWilleydouzzer
authored andcommitted
Address review comments, rename WOLFSSL_INTER_CA, use up_ref for get issuer
1 parent ee4e1b6 commit 6f0bcac

File tree

4 files changed

+9
-12
lines changed

4 files changed

+9
-12
lines changed

src/ssl.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5536,13 +5536,13 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
55365536
}
55375537

55385538
if (ret == 0 && cert->isCA == 0 && type != WOLFSSL_USER_CA &&
5539-
type != WOLFSSL_INTER_CA) {
5539+
type != WOLFSSL_TEMP_CA) {
55405540
WOLFSSL_MSG("\tCan't add as CA if not actually one");
55415541
ret = NOT_CA_ERROR;
55425542
}
55435543
#ifndef ALLOW_INVALID_CERTSIGN
55445544
else if (ret == 0 && cert->isCA == 1 && type != WOLFSSL_USER_CA &&
5545-
type != WOLFSSL_INTER_CA && !cert->selfSigned &&
5545+
type != WOLFSSL_TEMP_CA && !cert->selfSigned &&
55465546
(cert->extKeyUsage & KEYUSE_KEY_CERT_SIGN) == 0) {
55475547
/* Intermediate CA certs are required to have the keyCertSign
55485548
* extension set. User loaded root certs are not. */

src/ssl_certman.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ static int wolfSSL_CertManagerUnloadTempIntermediateCerts(
487487
WOLFSSL_CERT_MANAGER* cm)
488488
{
489489
WOLFSSL_ENTER("wolfSSL_CertManagerUnloadTempIntermediateCerts");
490-
return wolfSSL_CertManagerUnloadIntermediateCertsEx(cm, WOLFSSL_INTER_CA);
490+
return wolfSSL_CertManagerUnloadIntermediateCertsEx(cm, WOLFSSL_TEMP_CA);
491491
}
492492
#endif
493493

src/x509_str.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ WOLFSSL_X509_STORE_CTX* wolfSSL_X509_STORE_CTX_new_ex(void* heap)
7272
if (ctx != NULL &&
7373
wolfSSL_X509_STORE_CTX_init(ctx, NULL, NULL, NULL) !=
7474
WOLFSSL_SUCCESS) {
75-
XFREE(ctx, heap, DYNAMIC_TYPE_X509_CTX);
75+
wolfSSL_X509_STORE_CTX_free(ctx);
7676
ctx = NULL;
7777
}
7878
#endif
@@ -105,7 +105,6 @@ void wolfSSL_X509_STORE_CTX_free(WOLFSSL_X509_STORE_CTX* ctx)
105105

106106
if (ctx->current_issuer != NULL) {
107107
wolfSSL_X509_free(ctx->current_issuer);
108-
ctx->current_issuer = NULL;
109108
}
110109
#endif
111110

@@ -395,7 +394,7 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx)
395394
/* We found our issuer in the non-trusted cert list, add it
396395
* to the CM and verify the current cert against it */
397396
ret = X509StoreAddCa(ctx->store, issuer,
398-
WOLFSSL_INTER_CA);
397+
WOLFSSL_TEMP_CA);
399398
if (ret != WOLFSSL_SUCCESS) {
400399
goto exit;
401400
}
@@ -920,17 +919,15 @@ int wolfSSL_X509_STORE_CTX_get1_issuer(WOLFSSL_X509 **issuer,
920919

921920
ret = X509StoreGetIssuerEx(issuer, ctx->store->certs, x);
922921
if ((ret == WOLFSSL_SUCCESS) && (*issuer != NULL)) {
923-
*issuer = wolfSSL_X509_dup(*issuer);
924-
return (*issuer != NULL) ? WOLFSSL_SUCCESS : WOLFSSL_FAILURE;
922+
return wolfSSL_X509_up_ref(*issuer);
925923
}
926924

927925
#ifdef WOLFSSL_SIGNER_DER_CERT
928926
ret = x509GetIssuerFromCM(issuer, ctx->store->cm, x);
929927
#else
930928
ret = X509StoreGetIssuerEx(issuer, ctx->store->trusted, x);
931929
if ((ret == WOLFSSL_SUCCESS) && (*issuer != NULL)) {
932-
*issuer = wolfSSL_X509_dup(*issuer);
933-
return (*issuer != NULL) ? WOLFSSL_SUCCESS : WOLFSSL_FAILURE;
930+
return wolfSSL_X509_up_ref(*issuer);
934931
}
935932
#endif
936933

@@ -1065,7 +1062,7 @@ static void X509StoreFreeObjList(WOLFSSL_X509_STORE* store,
10651062
obj = wolfSSL_sk_X509_OBJECT_value(objs, i);
10661063
if (obj != NULL) {
10671064
obj->type = 0;
1068-
obj->data.x509 = NULL;
1065+
obj->data.ptr = NULL;
10691066
}
10701067
cnt--;
10711068
i--;

wolfssl/ssl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3325,7 +3325,7 @@ enum {
33253325

33263326
WOLFSSL_USER_CA = 1, /* user added as trusted */
33273327
WOLFSSL_CHAIN_CA = 2, /* added to cache from trusted chain */
3328-
WOLFSSL_INTER_CA = 3 /* Intermediate CA, only for use by
3328+
WOLFSSL_TEMP_CA = 3 /* Temp intermediate CA, only for use by
33293329
* X509_STORE */
33303330
};
33313331

0 commit comments

Comments
 (0)