Skip to content

Commit

Permalink
Don't be so strict client-side (#15546)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob committed Jul 19, 2018
1 parent 9c337bc commit dff2e4e
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions homeassistant/util/ssl.py
Expand Up @@ -6,21 +6,14 @@

def client_context():
"""Return an SSL context for making requests."""
context = _get_context()
context.verify_mode = ssl.CERT_REQUIRED
context.check_hostname = True
context.load_verify_locations(cafile=certifi.where(), capath=None)
context = ssl.create_default_context(
purpose=ssl.Purpose.SERVER_AUTH,
cafile=certifi.where()
)
return context


def server_context():
"""Return an SSL context for being a server."""
context = _get_context()
context.options |= ssl.OP_CIPHER_SERVER_PREFERENCE
return context


def _get_context():
"""Return an SSL context following the Mozilla recommendations.
TLS configuration follows the best-practice guidelines specified here:
Expand All @@ -31,7 +24,8 @@ def _get_context():

context.options |= (
ssl.OP_NO_SSLv2 | ssl.OP_NO_SSLv3 |
ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1
ssl.OP_NO_TLSv1 | ssl.OP_NO_TLSv1_1 |
ssl.OP_CIPHER_SERVER_PREFERENCE
)
if hasattr(ssl, 'OP_NO_COMPRESSION'):
context.options |= ssl.OP_NO_COMPRESSION
Expand Down

0 comments on commit dff2e4e

Please sign in to comment.