Skip to content

Commit b53cc0e

Browse files
committed
SSL: Loading bad private key
Fix ProcessBufferTryDecodeRsa and ProcessBufferTryDecodeEcc to only clear error when key format isn't known.
1 parent 6500444 commit b53cc0e

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

src/ssl.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6543,7 +6543,10 @@ static int ProcessBufferTryDecodeRsa(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
65436543
"not enabled to try");
65446544
ret = WOLFSSL_BAD_FILE;
65456545
#else
6546-
ret = 0; /* continue trying other algorithms */
6546+
if (*keyFormat == 0) {
6547+
/* Format unknown so keep trying. */
6548+
ret = 0; /* continue trying other algorithms */
6549+
}
65476550
#endif
65486551
}
65496552
else {
@@ -6616,7 +6619,10 @@ static int ProcessBufferTryDecodeRsa(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
66166619
"not enabled to try");
66176620
ret = WOLFSSL_BAD_FILE;
66186621
#else
6619-
ret = 0; /* continue trying other algorithms */
6622+
if (*keyFormat == 0) {
6623+
/* Format unknown so keep trying. */
6624+
ret = 0; /* continue trying other algorithms */
6625+
}
66206626
#endif
66216627
}
66226628
else {
@@ -6728,7 +6734,7 @@ static int ProcessBufferTryDecodeEcc(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
67286734
*resetSuites = 1;
67296735
}
67306736
}
6731-
else {
6737+
else if (*keyFormat == 0) {
67326738
ret = 0; /* continue trying other algorithms */
67336739
}
67346740

@@ -6809,7 +6815,7 @@ static int ProcessBufferTryDecodeEd25519(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
68096815
}
68106816
}
68116817
}
6812-
else {
6818+
else if (*keyFormat == 0) {
68136819
ret = 0; /* continue trying other algorithms */
68146820
}
68156821

0 commit comments

Comments
 (0)