Skip to content

Commit

Permalink
Merge pull request #9 from pagely/bugfix/ssl-import-error-handling
Browse files Browse the repository at this point in the history
Better error-handling
  • Loading branch information
mlteal authored Nov 21, 2018
2 parents 9c2025d + 20f981b commit de7417c
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions src/Command/SSL/CertImportCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

use GuzzleHttp\Exception\BadResponseException;

class CertImportCommand extends AbstractSSLCmd
{
protected $commandName = 'ssl:cert:import';
Expand Down Expand Up @@ -38,16 +40,17 @@ public function execute(InputInterface $input, OutputInterface $output)
$cert = $input->getArgument('cert');
$privateKey = $input->getArgument('privateKey');

$response = $this->api->import(
$this->token->token,
$input->getArgument('accountId'),
$this->getFile($input->getOption('csr')),
$this->getFile($input->getArgument('privateKey')),
$this->getFile($input->getArgument('cert')),
$this->getFile($input->getOption('chain'))
);

if ($response->getStatusCode() >= 400) {
try {
$response = $this->api->import(
$this->token->token,
$input->getArgument('accountId'),
$this->getFile($input->getOption('csr')),
$this->getFile($input->getArgument('privateKey')),
$this->getFile($input->getArgument('cert')),
$this->getFile($input->getOption('chain'))
);
} catch (BadResponseException $e) {
$response = $e->getResponse();
$this->output->writeln("<error>Could not import cert</error>");
$this->output->writeln($response->getStatusCode()." - ".$response->getBody()->getContents());
exit(1);
Expand Down

0 comments on commit de7417c

Please sign in to comment.