Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting 0 tickets to disable sending tickets in TLS 1.3 #347

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion scripts/tls.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,8 @@ def serverCmd(argv):
settings = HandshakeSettings()
settings.useExperimentalTackExtension=True
settings.dhParams = dhparam
settings.ticket_count = tickets or settings.ticket_count
if tickets is not None:
settings.ticket_count = tickets
if psk:
settings.pskConfigs = [(psk_ident, psk, psk_hash)]
settings.ticketKeys = [getRandomBytes(32)]
Expand Down
2 changes: 1 addition & 1 deletion tlslite/handshakesettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ def _sanityCheckTicketSettings(other):
if not 0 < other.max_early_data <= 2**64:
raise ValueError("max_early_data must be between 0 and 2GiB")

if not 0 < other.ticket_count < 2**16:
if not 0 <= other.ticket_count < 2**16:
raise ValueError("Incorrect amount for number of new session "
"tickets to send")

Expand Down
25 changes: 25 additions & 0 deletions unit_tests/test_tlslite_handshakesettings.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,31 @@ def test_none_as_record_size_limit(self):

self.assertIsNone(hs.record_size_limit)

def test_ticket_count_zero(self):
hs = HandshakeSettings()
hs.ticket_count = 0

hs = hs.validate()

self.assertIsNotNone(hs.ticket_count, 0)

def test_ticket_count_200(self):
hs = HandshakeSettings()
hs.ticket_count = 200

hs = hs.validate()

self.assertIsNotNone(hs.ticket_count, 200)

def test_ticket_count_negative(self):
hs = HandshakeSettings()
hs.ticket_count = -1

with self.assertRaises(ValueError) as e:
hs.validate()

self.assertIn("new session tickets", str(e.exception))


if __name__ == '__main__':
unittest.main()