mirror of
https://github.com/moepman/acertmgr.git
synced 2024-12-27 11:51:50 +01:00
Allow multiple sets of the same domain to defined in a single config file (necessary for multiple certs using different key_algorithm) in a list style notation (lists of maps)
This commit is contained in:
parent
1a98f86aad
commit
c3736c0838
@ -264,15 +264,29 @@ def load():
|
|||||||
os.path.abspath(domain_config_file) != os.path.abspath(global_config_file):
|
os.path.abspath(domain_config_file) != os.path.abspath(global_config_file):
|
||||||
with io.open(domain_config_file) as config_fd:
|
with io.open(domain_config_file) as config_fd:
|
||||||
try:
|
try:
|
||||||
for entry in json.load(config_fd).items():
|
data = json.load(config_fd)
|
||||||
domainconfigs.append(parse_config_entry(entry, globalconfig, runtimeconfig))
|
|
||||||
except ValueError:
|
except ValueError:
|
||||||
import yaml
|
import yaml
|
||||||
config_fd.seek(0)
|
config_fd.seek(0)
|
||||||
for entry in yaml.safe_load(config_fd).items():
|
data = yaml.safe_load(config_fd)
|
||||||
domainconfigs.append(parse_config_entry(entry, globalconfig, runtimeconfig))
|
if isinstance(data, list):
|
||||||
|
# Handle newer config in list format (allows for multiple entries with same domains)
|
||||||
|
entries = list()
|
||||||
|
for element in data:
|
||||||
|
entries += element.items()
|
||||||
|
else:
|
||||||
|
# Handle older config format with just one entry per same domain set
|
||||||
|
entries = data.items()
|
||||||
|
for entry in entries:
|
||||||
|
domainconfigs.append(parse_config_entry(entry, globalconfig, runtimeconfig))
|
||||||
|
|
||||||
# Define a fallback authority from global configuration / defaults
|
# Define a fallback authority from global configuration / defaults
|
||||||
runtimeconfig['fallback_authority'] = parse_authority([], globalconfig, runtimeconfig)
|
runtimeconfig['fallback_authority'] = parse_authority([], globalconfig, runtimeconfig)
|
||||||
|
|
||||||
return runtimeconfig, domainconfigs
|
return runtimeconfig, domainconfigs
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
# Simple configuration load test and output
|
||||||
|
from pprint import pprint
|
||||||
|
pprint(load())
|
||||||
|
Loading…
Reference in New Issue
Block a user