Skip to content

Commit 38892fd

Browse files
authored
Merge pull request #8757 from anhu/recalc_suites
Recalculate suites at ssl initialization.
2 parents f119086 + 43df11c commit 38892fd

1 file changed

Lines changed: 28 additions & 5 deletions

File tree

src/internal.c

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6922,13 +6922,36 @@ int SetSSL_CTX(WOLFSSL* ssl, WOLFSSL_CTX* ctx, int writeDup)
69226922
/* If we are setting the ctx on an already initialized SSL object
69236923
* then we possibly already have a side defined. Don't overwrite unless
69246924
* the context has a well defined role. */
6925-
if (newSSL || ctx->method->side != WOLFSSL_NEITHER_END)
6926-
ssl->options.side = (word16)(ctx->method->side);
6927-
ssl->options.downgrade = (word16)(ctx->method->downgrade);
6928-
ssl->options.minDowngrade = ctx->minDowngrade;
6929-
6925+
if (newSSL || ctx->method->side != WOLFSSL_NEITHER_END) {
6926+
ssl->options.side = (word16)(ctx->method->side);
6927+
}
6928+
ssl->options.downgrade = (word16)(ctx->method->downgrade);
6929+
ssl->options.minDowngrade = ctx->minDowngrade;
69306930
ssl->options.haveRSA = ctx->haveRSA;
69316931
ssl->options.haveDH = ctx->haveDH;
6932+
#if !defined(NO_CERTS) && !defined(NO_DH)
6933+
/* Its possible that DH algorithm parameters were set in the ctx, recalc
6934+
* cipher suites. */
6935+
if (ssl->options.haveDH && ctx->serverDH_P.buffer != NULL &&
6936+
ctx->serverDH_G.buffer != NULL) {
6937+
if (ssl->suites == NULL) {
6938+
if (AllocateSuites(ssl) != 0) {
6939+
return MEMORY_E;
6940+
}
6941+
}
6942+
InitSuites(ssl->suites, ssl->version, ssl->buffers.keySz,
6943+
ssl->options.haveRSA,
6944+
#ifdef NO_PSK
6945+
0,
6946+
#else
6947+
ctx->havePSK,
6948+
#endif
6949+
ssl->options.haveDH,
6950+
ssl->options.haveECDSAsig, ssl->options.haveECC, TRUE,
6951+
ssl->options.haveStaticECC, ssl->options.useAnon,
6952+
TRUE, TRUE, TRUE, TRUE, ssl->options.side);
6953+
}
6954+
#endif /* !NO_CERTS && !NO_DH */
69326955
ssl->options.haveECDSAsig = ctx->haveECDSAsig;
69336956
ssl->options.haveECC = ctx->haveECC;
69346957
ssl->options.haveStaticECC = ctx->haveStaticECC;

0 commit comments

Comments
 (0)