Skip to content

Commit 03f9b21

Browse files
authored
Merge pull request #7279 from SparkiDev/ssl_priv_load_fail
SSL: Loading bad private key
2 parents 6500444 + 9addb3e commit 03f9b21

1 file changed

Lines changed: 21 additions & 4 deletions

File tree

src/ssl.c

Lines changed: 21 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

@@ -6887,6 +6893,9 @@ static int ProcessBufferTryDecodeEd448(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
68876893
}
68886894
}
68896895
}
6896+
else if (*keyFormat == 0) {
6897+
ret = 0; /* continue trying other algorithms */
6898+
}
68906899

68916900
wc_ed448_free(key);
68926901
}
@@ -6991,6 +7000,10 @@ static int ProcessBufferTryDecodeFalcon(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
69917000
*resetSuites = 1;
69927001
}
69937002
}
7003+
else if (*keyFormat == 0) {
7004+
ret = 0; /* continue trying other algorithms */
7005+
}
7006+
69947007
wc_falcon_free(key);
69957008
}
69967009
XFREE(key, heap, DYNAMIC_TYPE_FALCON);
@@ -7105,6 +7118,10 @@ static int ProcessBufferTryDecodeDilithium(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
71057118
*resetSuites = 1;
71067119
}
71077120
}
7121+
else if (*keyFormat == 0) {
7122+
ret = 0; /* continue trying other algorithms */
7123+
}
7124+
71087125
wc_dilithium_free(key);
71097126
}
71107127
XFREE(key, heap, DYNAMIC_TYPE_DILITHIUM);

0 commit comments

Comments
 (0)