+1 for start simple and iterate;
but expecting a config object is not easy to add later.
class SSLConfig(dict):
def validate(self):
"""check types and (implementation-specific) ranges"""
class _BaseContext(metaclass=ABCMeta): #
def validate_config(self, cfg: Union[Dict, SSLConfig]) -> Boolean:
"""check types and (implementation-specific) ranges"""
if not hasattr(cfg, 'validate'):
cfg = SSLConfig(cfg)
cfg.validate()
self.cfg = cfg || return cfg
def set_config(self, cfg: Dict):
self.register_certificates(cfg[*])
self.set_ciphers(cfg[*])
self.set_inner_protocls(cfg[*])
if cfg.get(*) is not None:
self.set_sni_callback(cfg[*])
Why a configuration object makes sense here:
- Centralized config validation
- Implementations may have unique parameters
- Convenience: just pass the config params from {JSON, TOML, YAML, configobj, PasteDeploy, pyramid, ...} with sane validation