Skip to content
Snippets Groups Projects
Commit ec39a1d7 authored by Hans Trompert's avatar Hans Trompert
Browse files

always try to find key and certificate in config

parent 08bfac10
No related branches found
No related tags found
No related merge requests found
...@@ -315,6 +315,16 @@ class Config(object): ...@@ -315,6 +315,16 @@ class Config(object):
except configparser.NoOptionError: except configparser.NoOptionError:
vc[BASE_URL] = None vc[BASE_URL] = None
try:
vc[KEY] = cfg.get(BLOCK_SERVICE, KEY)
except configparser.NoOptionError:
vc[KEY] = None
try:
vc[CERTIFICATE] = cfg.get(BLOCK_SERVICE, CERTIFICATE)
except configparser.NoOptionError:
vc[CERTIFICATE] = None
try: try:
policies = cfg.get(BLOCK_SERVICE, POLICY).split(',') policies = cfg.get(BLOCK_SERVICE, POLICY).split(',')
for policy in policies: for policy in policies:
...@@ -356,18 +366,19 @@ class Config(object): ...@@ -356,18 +366,19 @@ class Config(object):
# tls # tls
if vc[TLS]: if vc[TLS]:
try: try:
hostkey = cfg.get(BLOCK_SERVICE, KEY) if not vc[KEY]:
hostcert = cfg.get(BLOCK_SERVICE, CERTIFICATE)
if not os.path.exists(hostkey):
raise ConfigurationError( raise ConfigurationError(
'Specified hostkey does not exist (%s)' % hostkey) 'must specify a key when TLS is enabled')
if not os.path.exists(hostcert): elif not os.path.exists(vc[KEY]):
raise ConfigurationError( raise ConfigurationError(
'Specified hostcert does not exist (%s)' % hostcert) 'Specified key does not exist (%s)' % vc[KEY])
vc[KEY] = hostkey if not vc[CERTIFICATE]:
vc[CERTIFICATE] = hostcert raise ConfigurationError(
'must specify a certificate when TLS is enabled')
elif not os.path.exists(vc[CERTIFICATE]):
raise ConfigurationError(
'Specified certificate does not exist (%s)' % vc[CERTIFICATE])
try: try:
allowed_hosts_cfg = cfg.get(BLOCK_SERVICE, ALLOWED_HOSTS) allowed_hosts_cfg = cfg.get(BLOCK_SERVICE, ALLOWED_HOSTS)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment