diff --git a/src/internal.c b/src/internal.c index c5dabefec..67c27f1f7 100644 --- a/src/internal.c +++ b/src/internal.c @@ -1851,8 +1851,7 @@ void SSL_CtxResourceFree(WOLFSSL_CTX* ctx) FreeDer(&ctx->certificate); #ifdef KEEP_OUR_CERT if (ctx->ourCert && ctx->ownOurCert) { - FreeX509(ctx->ourCert); - XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); + wolfSSL_X509_free(ctx->ourCert); ctx->ourCert = NULL; } #endif /* KEEP_OUR_CERT */ diff --git a/src/ssl.c b/src/ssl.c index 85c53a6e7..7077b8c88 100644 --- a/src/ssl.c +++ b/src/ssl.c @@ -5484,11 +5484,8 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, if (ssl->buffers.weOwnCert) { FreeDer(&ssl->buffers.certificate); #ifdef KEEP_OUR_CERT - FreeX509(ssl->ourCert); - if (ssl->ourCert) { - XFREE(ssl->ourCert, ssl->heap, DYNAMIC_TYPE_X509); - ssl->ourCert = NULL; - } + wolfSSL_X509_free(ssl->ourCert); + ssl->ourCert = NULL; #endif } ssl->buffers.certificate = der; @@ -5501,10 +5498,8 @@ int ProcessBuffer(WOLFSSL_CTX* ctx, const unsigned char* buff, FreeDer(&ctx->certificate); /* Make sure previous is free'd */ #ifdef KEEP_OUR_CERT if (ctx->ourCert) { - if (ctx->ownOurCert) { - FreeX509(ctx->ourCert); - XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); - } + if (ctx->ownOurCert) + wolfSSL_X509_free(ctx->ourCert); ctx->ourCert = NULL; } #endif @@ -14798,11 +14793,8 @@ int wolfSSL_set_compression(WOLFSSL* ssl) WOLFSSL_MSG("Unloading cert"); FreeDer(&ssl->buffers.certificate); #ifdef KEEP_OUR_CERT - FreeX509(ssl->ourCert); - if (ssl->ourCert) { - XFREE(ssl->ourCert, ssl->heap, DYNAMIC_TYPE_X509); - ssl->ourCert = NULL; - } + wolfSSL_X509_free(ssl->ourCert); + ssl->ourCert = NULL; #endif ssl->buffers.weOwnCert = 0; } @@ -42376,8 +42368,7 @@ err: x->derCert->length); #ifdef KEEP_OUR_CERT if (ctx->ourCert != NULL && ctx->ownOurCert) { - FreeX509(ctx->ourCert); - XFREE(ctx->ourCert, ctx->heap, DYNAMIC_TYPE_X509); + wolfSSL_X509_free(ctx->ourCert); } #ifndef WOLFSSL_X509_STORE_CERTS ctx->ourCert = x;