Skip to content

Commit 5670238

Browse files
committed
Don't call verify twice on the same error
1 parent 0530847 commit 5670238

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

src/internal.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16048,8 +16048,10 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1604816048

1604916049
/* Do verify callback. Don't call it on error as the callback
1605016050
* will still be called later. */
16051-
if (ret != 0)
16052-
ret = DoVerifyCallback(SSL_CM(ssl), ssl, ret, args);
16051+
if (ret != 0) {
16052+
args->leafVerifyErr = ret =
16053+
DoVerifyCallback(SSL_CM(ssl), ssl, ret, args);
16054+
}
1605316055

1605416056
if (ret == 0) {
1605516057
WOLFSSL_MSG("Verified Peer's cert");
@@ -16938,8 +16940,9 @@ int ProcessPeerCerts(WOLFSSL* ssl, byte* input, word32* inOutIdx,
1693816940
}
1693916941
#endif /* defined(__APPLE__) && defined(WOLFSSL_SYS_CA_CERTS) */
1694016942

16941-
/* Do verify callback */
16942-
ret = DoVerifyCallback(SSL_CM(ssl), ssl, ret, args);
16943+
/* Do leaf verify callback when it wasn't called yet */
16944+
if (ret == 0 || ret != args->leafVerifyErr)
16945+
ret = DoVerifyCallback(SSL_CM(ssl), ssl, ret, args);
1694316946

1694416947
if (ssl->options.verifyNone &&
1694516948
(ret == WC_NO_ERR_TRACE(CRL_MISSING) ||

wolfssl/internal.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2764,6 +2764,7 @@ typedef struct ProcPeerCertArgs {
27642764
int count;
27652765
int certIdx;
27662766
int lastErr;
2767+
int leafVerifyErr;
27672768
#ifdef WOLFSSL_TLS13
27682769
byte ctxSz;
27692770
#endif

0 commit comments

Comments
 (0)