Beispiel #1
0
    def handle_csr(self, parsed_args):
        """Process a --csr flag."""
        if parsed_args.verb != "certonly":
            raise errors.Error("Currently, a CSR file may only be specified "
                               "when obtaining a new or replacement "
                               "via the certonly command. Please try the "
                               "certonly command instead.")
        if parsed_args.allow_subset_of_names:
            raise errors.Error(
                "--allow-subset-of-names cannot be used with --csr")

        csrfile, contents = parsed_args.csr[0:2]
        typ, csr, domains = crypto_util.import_csr_file(csrfile, contents)

        # This is not necessary for webroot to work, however,
        # obtain_certificate_from_csr requires parsed_args.domains to be set
        for domain in domains:
            add_domains(parsed_args, domain)

        if not domains:
            # TODO: add CN to domains instead:
            raise errors.Error(
                "Unfortunately, your CSR %s needs to have a SubjectAltName for every domain"
                % parsed_args.csr[0])

        parsed_args.actual_csr = (csr, typ)

        csr_domains = {d.lower() for d in domains}
        config_domains = set(parsed_args.domains)
        if csr_domains != config_domains:
            raise errors.ConfigurationError(
                "Inconsistent domain requests:\nFrom the CSR: {0}\nFrom command line/config: {1}"
                .format(", ".join(csr_domains), ", ".join(config_domains)))
Beispiel #2
0
 def __call__(self,
              parser: argparse.ArgumentParser,
              namespace: argparse.Namespace,
              webroot_map: Union[str, Sequence[Any], None],
              option_string: Optional[str] = None) -> None:
     if webroot_map is None:
         return
     for domains, webroot_path in json.loads(str(webroot_map)).items():
         webroot_path = _validate_webroot(webroot_path)
         namespace.webroot_map.update(
             (d, webroot_path) for d in cli.add_domains(namespace, domains))
 def __call__(self, parser, namespace, webroot_map, option_string=None):
     for domains, webroot_path in six.iteritems(json.loads(webroot_map)):
         webroot_path = _validate_webroot(webroot_path)
         namespace.webroot_map.update(
             (d, webroot_path) for d in cli.add_domains(namespace, domains))