mirror of
				https://github.com/laurivosandi/certidude
				synced 2025-10-31 01:19:11 +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(" |    |") | ||||
|  | ||||
|     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")) | ||||
| #        if ca.certificate.email_address: | ||||
| #            click.echo("  \u2709 %s" % ca.certificate.email_address) | ||||
|   | ||||
| @@ -107,13 +107,28 @@ class CertificateAuthorityConfig(object): | ||||
|         authority = CertificateAuthority(slug, **dirs) | ||||
|         return authority | ||||
|  | ||||
|     def all_authorities(self): | ||||
|         for section in self._config: | ||||
|             if section.startswith("CA_"): | ||||
|                 try: | ||||
|                     yield self.instantiate_authority(section[3:]) | ||||
|                 except FileNotFoundError: | ||||
|                     pass | ||||
|  | ||||
|     def all_authorities(self, wanted=None): | ||||
|         for ca in self.ca_list: | ||||
|             if wanted and ca not in wanted: | ||||
|                 continue | ||||
|             try: | ||||
|                 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 wrapper(func): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user