Skip to content

Commit

Permalink
Disable the use of session tickets on TLSv1.2 by default
Browse files Browse the repository at this point in the history
Since currently session resumption is not supported by urllib3
there is no reason to request tickets from the server.
It takes up extra bytes in transit (~200 bytes), and raises some
minor security concerns.

See: https://blog.filippo.io/we-need-to-talk-about-session-tickets
  • Loading branch information
PleasantMachine9 committed Sep 25, 2020
1 parent 2a5c028 commit ed628df
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/urllib3/util/ssl_.py
Expand Up @@ -64,6 +64,12 @@ def _const_compare_digest_backport(a, b):
OP_NO_COMPRESSION = 0x20000


try: # OP_NO_TICKET was added in Python 3.6
from ssl import OP_NO_TICKET
except ImportError:
OP_NO_TICKET = 0x4000


# A secure default.
# Sources for more information on TLS ciphers:
#
Expand Down Expand Up @@ -250,7 +256,7 @@ def create_urllib3_context(
``ssl.CERT_REQUIRED``.
:param options:
Specific OpenSSL options. These default to ``ssl.OP_NO_SSLv2``,
``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``.
``ssl.OP_NO_SSLv3``, ``ssl.OP_NO_COMPRESSION``, and ``ssl.OP_NO_TICKET``.
:param ciphers:
Which cipher suites to allow the server to select.
:returns:
Expand All @@ -273,6 +279,11 @@ def create_urllib3_context(
# Disable compression to prevent CRIME attacks for OpenSSL 1.0+
# (issue #309)
options |= OP_NO_COMPRESSION
# TLSv1.2 only. Unless set explicitly, do not request tickets.
# This may save some bandwidth on wire, and although the ticket is encrypted,
# there is a risk associated with it being on wire,
# if the server is not rotating its ticketing keys properly.
options |= OP_NO_TICKET

context.options |= options

Expand Down

0 comments on commit ed628df

Please sign in to comment.