Skip to content

Commit a766dcb

Browse files
committed
harden SSL config and session
1 parent 5ba2d4a commit a766dcb

3 files changed

Lines changed: 19 additions & 8 deletions

File tree

src/ssl.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5798,8 +5798,12 @@ static int wolfSSL_parse_cipher_list(WOLFSSL_CTX* ctx, WOLFSSL* ssl,
57985798
tls13Only = 1;
57995799
if ((ctx != NULL && !IsAtLeastTLSv1_3(ctx->method->version)) ||
58005800
(ssl != NULL && !IsAtLeastTLSv1_3(ssl->version))) {
5801-
/* Silently ignore TLS 1.3 ciphers if we don't support it. */
5802-
return WOLFSSL_SUCCESS;
5801+
/* The list is exclusively TLS 1.3 suites but the context
5802+
* cannot negotiate TLS 1.3. Fail so the caller knows the
5803+
* restriction was not applied and does not proceed with
5804+
* whatever default suites remain active. */
5805+
WOLFSSL_MSG("TLS 1.3 cipher list on non-TLS-1.3 context");
5806+
return WOLFSSL_FAILURE;
58035807
}
58045808
}
58055809

@@ -10053,9 +10057,9 @@ size_t wolfSSL_get_client_random(const WOLFSSL* ssl, unsigned char* out,
1005310057
ssl->options.dtlsStateful = 0;
1005410058
#endif
1005510059
#if defined(HAVE_SESSION_TICKET) || !defined(NO_PSK)
10056-
ssl->options.noPskDheKe = 0;
10060+
ssl->options.noPskDheKe = ssl->ctx->noPskDheKe;
1005710061
#ifdef HAVE_SUPPORTED_CURVES
10058-
ssl->options.onlyPskDheKe = 0;
10062+
ssl->options.onlyPskDheKe = ssl->ctx->onlyPskDheKe;
1005910063
#endif
1006010064
#endif
1006110065
#ifdef HAVE_SESSION_TICKET

src/ssl_load.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5451,10 +5451,13 @@ int wolfSSL_CTX_set_default_verify_paths(WOLFSSL_CTX* ctx)
54515451
ret = 1;
54525452
}
54535453
#else
5454-
/* OpenSSL's implementation of this API does not require loading the
5455-
* system CA cert directory. Allow skipping this without erroring out.
5456-
*/
5457-
ret = 1;
5454+
/* No source available: SSL_CERT_DIR/SSL_CERT_FILE not set and
5455+
* WOLFSSL_SYS_CA_CERTS not compiled in. Returning success would be
5456+
* fail-open since no trust anchors were loaded. */
5457+
WOLFSSL_MSG("wolfSSL_CTX_set_default_verify_paths: no CA source "
5458+
"available (build without WOLFSSL_SYS_CA_CERTS and no "
5459+
"SSL_CERT_DIR/SSL_CERT_FILE env)");
5460+
ret = WOLFSSL_FAILURE;
54585461
#endif
54595462
}
54605463

src/ssl_sess.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1586,8 +1586,12 @@ int wolfSSL_SetSession(WOLFSSL* ssl, WOLFSSL_SESSION* session)
15861586
#if !defined(OPENSSL_EXTRA) || !defined(WOLFSSL_ERROR_CODE_OPENSSL)
15871587
return WOLFSSL_FAILURE; /* session timed out */
15881588
#else /* defined(OPENSSL_EXTRA) && defined(WOLFSSL_ERROR_CODE_OPENSSL) */
1589+
/* Return success for OpenSSL compatibility but do not carry the
1590+
* expired session's version/cipher into ssl state, which would
1591+
* otherwise pin the ClientHello to stale values. */
15891592
WOLFSSL_MSG("Session is expired but return success for "
15901593
"OpenSSL compatibility");
1594+
return WOLFSSL_SUCCESS;
15911595
#endif
15921596
}
15931597
ssl->options.resuming = 1;

0 commit comments

Comments
 (0)