Skip to content

Commit 6114691

Browse files
committed
ocsp: try lookup certificate using keyHash as KeyId
try to lookup the certificate using the key hash as key identifier first. If we can't find a certificate, it means that the certificate uses another method to compute the key identifier so we need to fallback to linear search.
1 parent 293719c commit 6114691

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/ssl.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5113,15 +5113,21 @@ Signer* GetCAByKeyHash(void* vp, const byte* keyHash)
51135113
if (cm == NULL || keyHash == NULL)
51145114
return NULL;
51155115

5116+
/* try lookup using keyHash as subjKeyID first */
5117+
ret = GetCA(vp, (byte*)keyHash);
5118+
if (ret != NULL && XMEMCMP(ret->subjectKeyHash, keyHash, KEYID_SIZE) == 0) {
5119+
return ret;
5120+
}
5121+
5122+
/* if we can't find the cert, we have to scan the full table */
51165123
if (wc_LockMutex(&cm->caLock) != 0)
51175124
return NULL;
51185125

51195126
/* Unfortunately we need to look through the entire table */
51205127
for (row = 0; row < CA_TABLE_SIZE && ret == NULL; row++) {
51215128
for (signers = cm->caTable[row]; signers != NULL;
51225129
signers = signers->next) {
5123-
if (XMEMCMP(signers->subjectKeyHash, keyHash, KEYID_SIZE)
5124-
== 0) {
5130+
if (XMEMCMP(signers->subjectKeyHash, keyHash, KEYID_SIZE) == 0) {
51255131
ret = signers;
51265132
break;
51275133
}

0 commit comments

Comments
 (0)