mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-08-02 20:24:39 +02:00
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.
This commit is contained in:
10
src/ssl.c
10
src/ssl.c
@@ -5113,6 +5113,13 @@ Signer* GetCAByKeyHash(void* vp, const byte* keyHash)
|
|||||||
if (cm == NULL || keyHash == NULL)
|
if (cm == NULL || keyHash == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
/* try lookup using keyHash as subjKeyID first */
|
||||||
|
ret = GetCA(vp, (byte*)keyHash);
|
||||||
|
if (ret != NULL && XMEMCMP(ret->subjectKeyHash, keyHash, KEYID_SIZE) == 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if we can't find the cert, we have to scan the full table */
|
||||||
if (wc_LockMutex(&cm->caLock) != 0)
|
if (wc_LockMutex(&cm->caLock) != 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@@ -5120,8 +5127,7 @@ Signer* GetCAByKeyHash(void* vp, const byte* keyHash)
|
|||||||
for (row = 0; row < CA_TABLE_SIZE && ret == NULL; row++) {
|
for (row = 0; row < CA_TABLE_SIZE && ret == NULL; row++) {
|
||||||
for (signers = cm->caTable[row]; signers != NULL;
|
for (signers = cm->caTable[row]; signers != NULL;
|
||||||
signers = signers->next) {
|
signers = signers->next) {
|
||||||
if (XMEMCMP(signers->subjectKeyHash, keyHash, KEYID_SIZE)
|
if (XMEMCMP(signers->subjectKeyHash, keyHash, KEYID_SIZE) == 0) {
|
||||||
== 0) {
|
|
||||||
ret = signers;
|
ret = signers;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user