get() public method

public get ( $name )
Example #1
0
 /**
  * @param Manager $args
  * @return \Generator
  */
 private function doExecute(Manager $args)
 {
     $server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
     $server = \Kelunik\AcmeClient\serverToKeyname($server);
     $path = \Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $server;
     $certificateStore = new CertificateStore($path);
     try {
         $pem = (yield $certificateStore->get($args->get("name")));
     } catch (CertificateStoreException $e) {
         $this->climate->br()->error("    Certificate not found.")->br();
         (yield new CoroutineResult(1));
         return;
     }
     $cert = new Certificate($pem);
     $this->climate->br();
     $this->climate->whisper("    Certificate is valid until " . date("d.m.Y", $cert->getValidTo()))->br();
     if ($args->defined("names")) {
         $names = array_map("trim", explode(",", $args->get("names")));
         $missingNames = array_diff($names, $cert->getNames());
         if ($missingNames) {
             $this->climate->comment("    The following names are not covered: " . implode(", ", $missingNames))->br();
             (yield new CoroutineResult(1));
             return;
         }
     }
     if ($cert->getValidTo() > time() + $args->get("ttl") * 24 * 60 * 60) {
         (yield new CoroutineResult(0));
         return;
     }
     $this->climate->comment("    Certificate is going to expire within the specified " . $args->get("ttl") . " days.")->br();
     (yield new CoroutineResult(1));
 }
Example #2
0
 /**
  * @param Manager $args
  * @return \Generator
  */
 private function doExecute(Manager $args)
 {
     $server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
     $keyName = \Kelunik\AcmeClient\serverToKeyname($server);
     $storage = \Kelunik\AcmeClient\normalizePath($args->get("storage"));
     try {
         $keyStore = new KeyStore($storage);
         (yield $keyStore->get("accounts/{$keyName}.pem"));
         $setup = true;
     } catch (KeyStoreException $e) {
         $setup = false;
     }
     $this->climate->br();
     $this->climate->out("  [" . ($setup ? "<green> ✓ </green>" : "<red> ✗ </red>") . "] " . ($setup ? "Registered on " : "Not yet registered on ") . $server);
     $this->climate->br();
     if ((yield \Amp\File\exists($storage . "/certs/{$keyName}"))) {
         $certificateStore = new CertificateStore($storage . "/certs/{$keyName}");
         $domains = (yield \Amp\File\scandir($storage . "/certs/{$keyName}"));
         foreach ($domains as $domain) {
             $pem = (yield $certificateStore->get($domain));
             $cert = new Certificate($pem);
             $symbol = time() > $cert->getValidTo() ? "<red> ✗ </red>" : "<green> ✓ </green>";
             if (time() < $cert->getValidTo() && time() + $args->get("ttl") * 24 * 60 * 60 > $cert->getValidTo()) {
                 $symbol = "<yellow> ⭮ </yellow>";
             }
             $this->climate->out("  [" . $symbol . "] " . implode(", ", $cert->getNames()));
         }
         $this->climate->br();
     }
 }