Skip to content
Open
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
16 changes: 16 additions & 0 deletions prometheus_client/exposition.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,22 @@ def _get_ssl_ctx(
"""Load context supports SSL."""
ssl_cxt = ssl.SSLContext(protocol=protocol)

# The following chipers will be removed if the default cipher set contains
# them. The reason for each cipher is stated in the comment.
remove_cipher_names = [
"ECDHE-ECDSA-AES256-SHA384", # is a CBC cipher (CVE-2013-0169)
"ECDHE-RSA-AES256-SHA384", # is a CBC cipher (CVE-2013-0169)
"ECDHE-ECDSA-AES128-SHA256", # is a CBC cipher (CVE-2013-0169)
"ECDHE-RSA-AES128-SHA256", # is a CBC cipher (CVE-2013-0169)
]
cipher_names = [c['name'] for c in ssl_cxt.get_ciphers()]
for cipher_name in remove_cipher_names:
try:
cipher_names.remove(cipher_name)
except ValueError:
pass
ssl_cxt.set_ciphers(':'.join(cipher_names))

if cafile is not None or capath is not None:
try:
ssl_cxt.load_verify_locations(cafile, capath)
Expand Down