Kelunik\AcmeClient\Stores\KeyStore::get PHP Method

get() public method

public get ( $path )
    public function get($path)
    {
        if (!is_string($path)) {
            throw new InvalidArgumentException(sprintf("\$root must be of type string, %s given.", gettype($path)));
        }
        return \Amp\resolve($this->doGet($path));
    }

Usage Example

Example #1
0
 private function doExecute(Manager $args)
 {
     $keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")));
     $server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
     $keyFile = \Kelunik\AcmeClient\serverToKeyname($server);
     $keyPair = (yield $keyStore->get("accounts/{$keyFile}.pem"));
     $acme = $this->acmeFactory->build($server, $keyPair);
     $this->climate->br();
     $this->climate->whisper("    Revoking certificate ...");
     $path = \Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $keyFile . "/" . $args->get("name") . "/cert.pem";
     try {
         $pem = (yield \Amp\File\get($path));
         $cert = new Certificate($pem);
     } catch (FilesystemException $e) {
         throw new \RuntimeException("There's no such certificate (" . $path . ")");
     }
     if ($cert->getValidTo() < time()) {
         $this->climate->comment("    Certificate did already expire, no need to revoke it.");
     }
     $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->br();
     $this->climate->info("    Certificate has been revoked.");
     (yield (new CertificateStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $keyFile))->delete($args->get("name")));
     (yield new CoroutineResult(0));
 }
All Usage Examples Of Kelunik\AcmeClient\Stores\KeyStore::get