Skip to content

Commit

Permalink
modify Config for subclassing create_ssl_context
Browse files Browse the repository at this point in the history
This allows a subclass to decide how, and crucially where, the
certificates for the SSL conext are loaded.
  • Loading branch information
dholth authored and pgjones committed Jul 8, 2019
1 parent aae3c31 commit 25348c2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions hypercorn/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,9 @@ def create_ssl_context(self) -> Optional[SSLContext]:
context.options |= ssl.OP_NO_COMPRESSION # RFC 7540 Section 9.2.1: MUST disable compression
context.set_alpn_protocols(self.alpn_protocols)

context.load_cert_chain(certfile=self.certfile, keyfile=self.keyfile)
if self.certfile is not None and self.keyfile is not None:
context.load_cert_chain(certfile=self.certfile, keyfile=self.keyfile)

if self.ca_certs is not None:
context.load_verify_locations(self.ca_certs)
if self.verify_mode is not None:
Expand Down Expand Up @@ -206,7 +208,7 @@ def from_mapping(
config = {'keep_alive_timeout': 10}
Config.from_mapping(config)
Config.form_mapping(keep_alive_timeout=10)
Config.from_mapping(keep_alive_timeout=10)
Arguments:
mapping: Optionally a mapping object.
Expand Down

0 comments on commit 25348c2

Please sign in to comment.