Cleaner code logic

This commit is contained in:
Andrew Morgan 2019-04-01 14:56:36 +01:00
parent ffc9c10b6e
commit da23aa26c5

View file

@ -138,12 +138,10 @@ class ClientTLSOptionsFactory(object):
# Use _makeContext so that we get a fresh OpenSSL CTX each time. # Use _makeContext so that we get a fresh OpenSSL CTX each time.
# Check if certificate validation has been enabled # Check if certificate validation has been enabled
if config.federation_verify_certificates: if (config.federation_verify_certificates and
# Check if this host is whitelisted host not in config.federation_certificate_validation_whitelist):
if host in config.federation_certificate_validation_whitelist: # Require validation
return ClientTLSOptions(host, self._options_novalidate._makeContext())
# Otherwise require validation
return ClientTLSOptions(host, self._options_validate._makeContext()) return ClientTLSOptions(host, self._options_validate._makeContext())
# Otherwise don't require validation
return ClientTLSOptions(host, self._options_novalidate._makeContext()) return ClientTLSOptions(host, self._options_novalidate._makeContext())