protected function execute(InputInterface $input, OutputInterface $output)
{
$repository = $this->getRepository();
$client = $this->getClient();
$domain = $input->getArgument('domain');
$solverName = strtolower($input->getOption('solver'));
/** @var SolverLocator $solverLocator */
$solverLocator = $this->getContainer()->get('challenge_solver.locator');
if (!$solverLocator->hasSolver($solverName)) {
throw new \UnexpectedValueException(sprintf('The solver "%s" does not exists. Available solvers are: (%s)', $solverName, implode(', ', $solverLocator->getSolversName())));
}
/** @var SolverInterface $solver */
$solver = $solverLocator->getSolver($solverName);
/** @var ValidatorInterface $validator */
$validator = $this->getContainer()->get('challenge_validator');
$output->writeln(sprintf('<info>Loading the authorization token for domain %s ...</info>', $domain));
$authorizationChallenge = $repository->loadDomainAuthorizationChallenge($domain);
if (!$solver->supports($authorizationChallenge)) {
throw new ChallengeNotSupportedException();
}
if (!$input->getOption('no-test')) {
$output->writeln('<info>Testing the challenge...</info>');
if (!$validator->isValid($authorizationChallenge)) {
throw new ChallengeNotSupportedException();
}
}
$output->writeln(sprintf('<info>Requesting authorization check for domain %s ...</info>', $domain));
$client->challengeAuthorization($authorizationChallenge);
$this->output->writeln(sprintf(<<<'EOF'
<info>The authorization check was successful!</info>
You are now the proved owner of the domain %s.
<info>Please note that you won't need to prove it anymore as long as you keep the same account key pair.</info>
You can now request a certificate for your domain:
php <info>%s request</info> %s
EOF
, $domain, $_SERVER['PHP_SELF'], $domain));
$solver->cleanup($authorizationChallenge);
}