TLS 1.3 sessions should not be added to the server session cache.
Fix this and add a test. Otherwise enabling TLS 1.3 will cause a server to blow through its session cache. Change-Id: I67edbc468faedfd94a6c30cf842af085a6543b50 Reviewed-on: https://boringssl-review.googlesource.com/13501 Reviewed-by: Steven Valdez <svaldez@google.com> Reviewed-by: David Benjamin <davidben@google.com> Commit-Queue: David Benjamin <davidben@google.com> CQ-Verified: CQ bot account: commit-bot@chromium.org <commit-bot@chromium.org>
This commit is contained in:
parent
c26692cfdd
commit
b5c58db9ff
@ -493,7 +493,7 @@ int ssl_get_new_session(SSL_HANDSHAKE *hs, int is_server) {
|
|||||||
session->timeout = ssl->session_timeout;
|
session->timeout = ssl->session_timeout;
|
||||||
|
|
||||||
if (is_server) {
|
if (is_server) {
|
||||||
if (hs->ticket_expected) {
|
if (hs->ticket_expected || ssl3_protocol_version(ssl) >= TLS1_3_VERSION) {
|
||||||
/* Don't set session IDs for sessions resumed with tickets. This will keep
|
/* Don't set session IDs for sessions resumed with tickets. This will keep
|
||||||
* them out of the session cache. */
|
* them out of the session cache. */
|
||||||
session->session_id_length = 0;
|
session->session_id_length = 0;
|
||||||
|
@ -1254,6 +1254,17 @@ static bool CheckHandshakeProperties(SSL *ssl, bool is_resume) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!is_resume) {
|
||||||
|
if (config->expect_session_id && !GetTestState(ssl)->got_new_session) {
|
||||||
|
fprintf(stderr, "session was not cached on the server.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (config->expect_no_session_id && GetTestState(ssl)->got_new_session) {
|
||||||
|
fprintf(stderr, "session was unexpectedly cached on the server.\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (config->is_server && !GetTestState(ssl)->early_callback_called) {
|
if (config->is_server && !GetTestState(ssl)->early_callback_called) {
|
||||||
fprintf(stderr, "early callback not called\n");
|
fprintf(stderr, "early callback not called\n");
|
||||||
return false;
|
return false;
|
||||||
|
@ -3417,6 +3417,7 @@ func addStateMachineCoverageTests(config stateMachineTestConfig) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
resumeSession: true,
|
resumeSession: true,
|
||||||
|
flags: []string{"-expect-no-session-id"},
|
||||||
})
|
})
|
||||||
tests = append(tests, testCase{
|
tests = append(tests, testCase{
|
||||||
testType: serverTest,
|
testType: serverTest,
|
||||||
@ -3426,6 +3427,7 @@ func addStateMachineCoverageTests(config stateMachineTestConfig) {
|
|||||||
SessionTicketsDisabled: true,
|
SessionTicketsDisabled: true,
|
||||||
},
|
},
|
||||||
resumeSession: true,
|
resumeSession: true,
|
||||||
|
flags: []string{"-expect-session-id"},
|
||||||
})
|
})
|
||||||
tests = append(tests, testCase{
|
tests = append(tests, testCase{
|
||||||
testType: serverTest,
|
testType: serverTest,
|
||||||
@ -3467,6 +3469,9 @@ func addStateMachineCoverageTests(config stateMachineTestConfig) {
|
|||||||
},
|
},
|
||||||
resumeSession: true,
|
resumeSession: true,
|
||||||
resumeRenewedSession: true,
|
resumeRenewedSession: true,
|
||||||
|
// TLS 1.3 uses tickets, so the session should not be
|
||||||
|
// cached statefully.
|
||||||
|
flags: []string{"-expect-no-session-id"},
|
||||||
})
|
})
|
||||||
|
|
||||||
tests = append(tests, testCase{
|
tests = append(tests, testCase{
|
||||||
|
@ -123,6 +123,8 @@ const Flag<bool> kBoolFlags[] = {
|
|||||||
&TestConfig::expect_secure_renegotiation },
|
&TestConfig::expect_secure_renegotiation },
|
||||||
{ "-expect-no-secure-renegotiation",
|
{ "-expect-no-secure-renegotiation",
|
||||||
&TestConfig::expect_no_secure_renegotiation },
|
&TestConfig::expect_no_secure_renegotiation },
|
||||||
|
{ "-expect-session-id", &TestConfig::expect_session_id },
|
||||||
|
{ "-expect-no-session-id", &TestConfig::expect_no_session_id },
|
||||||
};
|
};
|
||||||
|
|
||||||
const Flag<std::string> kStringFlags[] = {
|
const Flag<std::string> kStringFlags[] = {
|
||||||
|
@ -131,6 +131,8 @@ struct TestConfig {
|
|||||||
bool expect_no_secure_renegotiation = false;
|
bool expect_no_secure_renegotiation = false;
|
||||||
int max_send_fragment = 0;
|
int max_send_fragment = 0;
|
||||||
int read_size = 0;
|
int read_size = 0;
|
||||||
|
bool expect_session_id = false;
|
||||||
|
bool expect_no_session_id = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool ParseConfig(int argc, char **argv, TestConfig *out_config);
|
bool ParseConfig(int argc, char **argv, TestConfig *out_config);
|
||||||
|
Loading…
Reference in New Issue
Block a user