@@ -20152,10 +20152,11 @@ WOLFSSL_CTX* wolfSSL_set_SSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
2015220152
2015320153#ifndef NO_CERTS
2015420154#ifdef WOLFSSL_COPY_CERT
20155- /* If WOLFSSL_COPY_CERT defined, make new copy of cert from ctx
20156- * unless SSL object already has a cert */
20157- if ((ctx->certificate != NULL) &&
20158- (ssl->buffers.certificate == NULL)) {
20155+ /* If WOLFSSL_COPY_CERT defined, always make new copy of cert from ctx */
20156+ if (ctx->certificate != NULL) {
20157+ if (ssl->buffers.certificate != NULL) {
20158+ FreeDer(&ssl->buffers.certificate);
20159+ }
2015920160 ret = AllocCopyDer(&ssl->buffers.certificate, ctx->certificate->buffer,
2016020161 ctx->certificate->length, ctx->certificate->type,
2016120162 ctx->certificate->heap);
@@ -20166,8 +20167,10 @@ WOLFSSL_CTX* wolfSSL_set_SSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx)
2016620167 ssl->buffers.weOwnCert = 1;
2016720168 ret = WOLFSSL_SUCCESS;
2016820169 }
20169- if ((ctx->certChain != NULL) &&
20170- (ssl->buffers.certChain == NULL)) {
20170+ if (ctx->certChain != NULL) {
20171+ if (ssl->buffers.certChain != NULL) {
20172+ FreeDer(&ssl->buffers.certChain);
20173+ }
2017120174 ret = AllocCopyDer(&ssl->buffers.certChain, ctx->certChain->buffer,
2017220175 ctx->certChain->length, ctx->certChain->type,
2017320176 ctx->certChain->heap);
0 commit comments