Register or update a domain certificate for this env.

def certify(self, no_confirm=True, manual=False):
        """
        Register or update a domain certificate for this env.
        """

        if not self.domain:
            raise ClickException("Can't certify a domain without " + click.style("domain", fg="red", bold=True) + " configured!")

        if not no_confirm: # pragma: no cover
            confirm = input("Are you sure you want to certify? [y/n] ")
            if confirm != 'y':
                return

        # Make sure this isn't already deployed.
        deployed_versions = self.zappa.get_lambda_function_versions(self.lambda_name)
        if len(deployed_versions) == 0:
            raise ClickException("This application " + click.style("isn't deployed yet", fg="red") +
                                 " - did you mean to call " + click.style("deploy", bold=True) + "?")


        account_key_location = self.stage_config.get('lets_encrypt_key', None)
        cert_location = self.stage_config.get('certificate', None)
        cert_key_location = self.stage_config.get('certificate_key', None)
        cert_chain_location = self.stage_config.get('certificate_chain', None)
        cert_arn = self.stage_config.get('certificate_arn', None)
        base_path = self.stage_config.get('base_path', None)

        # These are sensitive
        certificate_body = None
        certificate_private_key = None
        certificate_chain = None

        # Prepare for custom Let's Encrypt
        if not cert_location and not cert_arn:
            if not account_key_location:
                raise ClickException("Can't certify a domain without " + click.style("lets_encrypt_key", fg="red", bold=True) +
                                     " or " + click.style("certificate", fg="red", bold=True)+
                                     " or " + click.style("certificate_arn", fg="red", bold=True) + " configured!")

            # Get install account_key to /tmp/account_key.pem
            from .letsencrypt import gettempdir
            if account_key_location.startswith('s3://'):
                bucket, key_name = parse_s3_url(account_key_location)
                self.zappa.s3_client.download_file(bucket, key_name, os.path.join(gettempdir(), 'account.key'))
            else:
                from shutil import copyfile
                copyfile(account_key_location, os.path.join(gettempdir(), 'account.key'))

        # Prepare for Custom SSL
        elif not account_key_location and not cert_arn:
            if not cert_location or not cert_key_location or not cert_chain_location:
                raise ClickException("Can't certify a domain without " +
                                     click.style("certificate, certificate_key and certificate_chain", fg="red", bold=True) + " configured!")

            # Read the supplied certificates.
            with open(cert_location) as f:
                certificate_body = f.read()

            with open(cert_key_location) as f:
                certificate_private_key = f.read()

            with open(cert_chain_location) as f:
                certificate_chain = f.read()


        click.echo("Certifying domain " + click.style(self.domain, fg="green", bold=True) + "..")

        # Get cert and update domain.

        # Let's Encrypt
        if not cert_location and not cert_arn:
            from .letsencrypt import get_cert_and_update_domain
            cert_success = get_cert_and_update_domain(
                    self.zappa,
                    self.lambda_name,
                    self.api_stage,
                    self.domain,
                    manual
                )

        # Custom SSL / ACM
        else:
            route53 = self.stage_config.get('route53_enabled', True)
            if not self.zappa.get_domain_name(self.domain, route53=route53):
                dns_name = self.zappa.create_domain_name(
                    domain_name=self.domain,
                    certificate_name=self.domain + "-Zappa-Cert",
                    certificate_body=certificate_body,
                    certificate_private_key=certificate_private_key,
                    certificate_chain=certificate_chain,
                    certificate_arn=cert_arn,
                    lambda_name=self.lambda_name,
                    stage=self.api_stage,
                    base_path=base_path
                )
                if route53:
                    self.zappa.update_route53_records(self.domain, dns_name)
                print("Created a new domain name with supplied certificate. Please note that it can take up to 40 minutes for this domain to be "
                      "created and propagated through AWS, but it requires no further work on your part.")
            else:
                self.zappa.update_domain_name(
                    domain_name=self.domain,
                    certificate_name=self.domain + "-Zappa-Cert",
                    certificate_body=certificate_body,
                    certificate_private_key=certificate_private_key,
                    certificate_chain=certificate_chain,
                    certificate_arn=cert_arn,
                    lambda_name=self.lambda_name,
                    stage=self.api_stage,
                    route53=route53,
                    base_path=base_path
                )

            cert_success = True

        if cert_success:
            click.echo("Certificate " + click.style("updated", fg="green", bold=True) + "!")
        else:
            click.echo(click.style("Failed", fg="red", bold=True) + " to generate or install certificate! :(")
            click.echo("\n==============\n")
            shamelessly_promote()