Improve output for various commands

This commit is contained in:
Niklas Keller
2016-03-23 23:58:20 +01:00
parent dd34937e96
commit 266cc06746
3 changed files with 26 additions and 14 deletions

View File

@@ -75,8 +75,9 @@ class Issue implements Command {
throw new AcmeException("Account key not found, did you run 'bin/acme setup'?", 0, $e);
}
$acme = new AcmeService(new AcmeClient($server, $keyPair));
$this->climate->br();
$acme = new AcmeService(new AcmeClient($server, $keyPair));
$promises = [];
foreach ($domains as $i => $domain) {
@@ -103,7 +104,8 @@ class Issue implements Command {
$keyPair = (yield $keyStore->put($path, $keyPair));
}
$this->climate->info("Requesting certificate ...");
$this->climate->br();
$this->climate->whisper(" Requesting certificate ...");
$location = (yield $acme->requestCertificate($keyPair, $domains));
$certificates = (yield $acme->pollForCertificate($location));
@@ -112,7 +114,8 @@ class Issue implements Command {
$certificateStore = new CertificateStore($path);
yield $certificateStore->put($certificates);
$this->climate->info("Successfully issued certificate, see {$path}/" . reset($domains));
$this->climate->info(" Successfully issued certificate.");
$this->climate->info(" See {$path}/" . reset($domains));
yield new CoroutineResult(0);
}
@@ -134,7 +137,7 @@ class Issue implements Command {
$payload = $acme->generateHttp01Payload($keyPair, $token);
$this->climate->whisper("Providing payload at http://{$domain}/.well-known/acme-challenge/{$token}");
$this->climate->whisper(" Providing payload at http://{$domain}/.well-known/acme-challenge/{$token}");
$challengeStore = new ChallengeStore($path);
@@ -145,7 +148,7 @@ class Issue implements Command {
yield $acme->answerChallenge($challenge->uri, $payload);
yield $acme->pollForChallenge($location);
$this->climate->info("{$domain} is now authorized.");
$this->climate->comment(" {$domain} is now authorized.");
yield $challengeStore->delete($token);
} catch (Exception $e) {

View File

@@ -32,7 +32,8 @@ class Revoke implements Command {
$keyPair = (yield $keyStore->get("accounts/{$keyFile}.pem"));
$acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair);
$this->climate->info("Revoking certificate ...");
$this->climate->br();
$this->climate->whisper(" Revoking certificate ...");
$path = \Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $keyFile . "/" . $args->get("name") . "/cert.pem";
@@ -44,12 +45,17 @@ class Revoke implements Command {
}
if ($cert->getValidTo() < time()) {
$this->climate->info("Certificate did already expire, no need to revoke it.");
$this->climate->comment(" Certificate did already expire, no need to revoke it.");
}
$this->climate->info("Certificate was valid for: " . implode(", ", $cert->getNames()));
$names = $cert->getNames();
$this->climate->whisper(" Certificate was valid for " . count($names) . " domains.");
$this->climate->whisper(" - " . implode(PHP_EOL . " - ", $names) . PHP_EOL);
yield $acme->revokeCertificate($pem);
$this->climate->info("Certificate has been revoked.");
$this->climate->br();
$this->climate->info(" Certificate has been revoked.");
yield (new CertificateStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")). "/certs/" . $keyFile))->delete($args->get("name"));

View File

@@ -39,25 +39,28 @@ class Setup implements Command {
$keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")));
$this->climate->br();
try {
$keyPair = (yield $keyStore->get($path));
$this->climate->info("Existing private key successfully loaded.");
$this->climate->whisper(" Using existing private key ...");
} catch (KeyStoreException $e) {
$this->climate->info("No private key found, generating new one ...");
$this->climate->whisper(" No private key found, generating new one ...");
$keyPair = (new OpenSSLKeyGenerator)->generate($bits);
$keyPair = (yield $keyStore->put($path, $keyPair));
$this->climate->info("Generated new private key with {$bits} bits.");
$this->climate->whisper(" Generated new private key with {$bits} bits.");
}
$acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair);
$this->climate->info("Registering with ACME server " . substr($server, 8) . " ...");
$this->climate->whisper(" Registering with " . substr($server, 8) . " ...");
/** @var Registration $registration */
$registration = (yield $acme->register($email));
$this->climate->whisper("Registration successful with the following contact information: " . implode(", ", $registration->getContact()));
$this->climate->info(" Registration successful. Contacts: " . implode(", ", $registration->getContact()));
$this->climate->br();
yield new CoroutineResult(0);
}