mirror of
https://github.com/laurivosandi/certidude
synced 2024-12-23 00:25:18 +00:00
cli: Fix 'certidude list [CA]...' command
This commit is contained in:
parent
f73885fe70
commit
91d09629e2
@ -646,7 +646,15 @@ def certidude_list(ca, show_key_type, show_extensions, show_path):
|
|||||||
click.echo(" | |")
|
click.echo(" | |")
|
||||||
|
|
||||||
config = load_config()
|
config = load_config()
|
||||||
for ca in config.all_authorities():
|
|
||||||
|
wanted_list = None
|
||||||
|
if ca:
|
||||||
|
missing = list(set(ca) - set(config.ca_list))
|
||||||
|
if missing:
|
||||||
|
raise click.NoSuchOption(option_name='', message="Unable to find certificate authority.", possibilities=config.ca_list)
|
||||||
|
wanted_list = ca
|
||||||
|
|
||||||
|
for ca in config.all_authorities(wanted_list):
|
||||||
click.echo("Certificate authority " + click.style(ca.slug, fg="blue"))
|
click.echo("Certificate authority " + click.style(ca.slug, fg="blue"))
|
||||||
# if ca.certificate.email_address:
|
# if ca.certificate.email_address:
|
||||||
# click.echo(" \u2709 %s" % ca.certificate.email_address)
|
# click.echo(" \u2709 %s" % ca.certificate.email_address)
|
||||||
|
@ -107,13 +107,28 @@ class CertificateAuthorityConfig(object):
|
|||||||
authority = CertificateAuthority(slug, **dirs)
|
authority = CertificateAuthority(slug, **dirs)
|
||||||
return authority
|
return authority
|
||||||
|
|
||||||
def all_authorities(self):
|
|
||||||
for section in self._config:
|
def all_authorities(self, wanted=None):
|
||||||
if section.startswith("CA_"):
|
for ca in self.ca_list:
|
||||||
try:
|
if wanted and ca not in wanted:
|
||||||
yield self.instantiate_authority(section[3:])
|
continue
|
||||||
except FileNotFoundError:
|
try:
|
||||||
pass
|
yield self.instantiate_authority(ca)
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@property
|
||||||
|
def ca_list(self):
|
||||||
|
"""
|
||||||
|
Returns sorted list of CA-s defined in the configuration file.
|
||||||
|
"""
|
||||||
|
l = [s[3:] for s in self._config if s.startswith("CA_")]
|
||||||
|
# Sanity check for duplicates (although ConfigParser fails earlier)
|
||||||
|
if len(l) != len(set(l)):
|
||||||
|
raise ValueError
|
||||||
|
return sorted(l)
|
||||||
|
|
||||||
|
|
||||||
def pop_certificate_authority(self):
|
def pop_certificate_authority(self):
|
||||||
def wrapper(func):
|
def wrapper(func):
|
||||||
|
Loading…
Reference in New Issue
Block a user