mirror of
				https://github.com/laurivosandi/certidude
				synced 2025-10-31 09:29:13 +00:00 
			
		
		
		
	cli: Fix 'certidude list [CA]...' command
This commit is contained in:
		| @@ -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,14 +107,29 @@ 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: | ||||||
|  |             if wanted and ca not in wanted: | ||||||
|  |                 continue | ||||||
|             try: |             try: | ||||||
|                     yield self.instantiate_authority(section[3:]) |                 yield self.instantiate_authority(ca) | ||||||
|             except FileNotFoundError: |             except FileNotFoundError: | ||||||
|                 pass |                 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): | ||||||
|             def wrapped(*args, **kwargs): |             def wrapped(*args, **kwargs): | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user