Skip to content

Commit 83e3467

Browse files
Add type parameter to RemoveCA to avoid removing CAs of the wrong type.
1 parent 96dba11 commit 83e3467

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/ssl.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6093,7 +6093,7 @@ int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify)
60936093
}
60946094

60956095
/* Removes the CA with the passed in subject hash from the cert manager's CA cert store. */
6096-
int RemoveCA(WOLFSSL_CERT_MANAGER* cm, byte* hash)
6096+
int RemoveCA(WOLFSSL_CERT_MANAGER* cm, byte* hash, byte type)
60976097
{
60986098
Signer* current;
60996099
Signer* prev;
@@ -6120,7 +6120,8 @@ int RemoveCA(WOLFSSL_CERT_MANAGER* cm, byte* hash)
61206120
subjectHash = current->subjectNameHash;
61216121
#endif
61226122

6123-
if (XMEMCMP(hash, subjectHash, SIGNER_DIGEST_SIZE) == 0) {
6123+
if ((current->type == type) &&
6124+
(XMEMCMP(hash, subjectHash, SIGNER_DIGEST_SIZE) == 0)) {
61246125
if (current == cm->caTable[row]) {
61256126
cm->caTable[row] = cm->caTable[row]->next;
61266127
}

src/x509_str.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ int wolfSSL_X509_verify_cert(WOLFSSL_X509_STORE_CTX* ctx)
571571
* cert with the same subject key which will work. Retry until all
572572
* possible candidate certs are exhausted. */
573573
WOLFSSL_MSG("X509_verify_cert current cert failed, retrying with other certs.");
574-
RemoveCA(ctx->store->cm, ctx->current_cert->subjKeyId);
574+
RemoveCA(ctx->store->cm, ctx->current_cert->subjKeyId, WOLFSSL_TEMP_CA);
575575
X509StorePopCert(certs, failedCerts, ctx->current_cert);
576576
if (numInterAdd > 0)
577577
numInterAdd--;

wolfssl/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4260,7 +4260,7 @@ int ProcessOldClientHello(WOLFSSL* ssl, const byte* input, word32* inOutIdx,
42604260
WOLFSSL_LOCAL int AddSigner(WOLFSSL_CERT_MANAGER* cm, Signer *s);
42614261
WOLFSSL_LOCAL
42624262
int AddCA(WOLFSSL_CERT_MANAGER* cm, DerBuffer** pDer, int type, int verify);
4263-
WOLFSSL_LOCAL int RemoveCA(WOLFSSL_CERT_MANAGER* cm, byte* hash);
4263+
WOLFSSL_LOCAL int RemoveCA(WOLFSSL_CERT_MANAGER* cm, byte* hash, byte type);
42644264
WOLFSSL_LOCAL
42654265
int AlreadySigner(WOLFSSL_CERT_MANAGER* cm, byte* hash);
42664266
#ifdef WOLFSSL_TRUST_PEER_CERT

0 commit comments

Comments
 (0)