Implement storage defaulting to the old one and required when using as PHAR

This commit is contained in:
Niklas Keller
2016-03-23 19:33:26 +01:00
parent 1a06a5cadf
commit 9ea97f18e1
6 changed files with 74 additions and 16 deletions

View File

@@ -23,7 +23,7 @@ class Revoke implements Command {
}
private function doExecute(Manager $args) {
$keyStore = new KeyStore(dirname(dirname(__DIR__)) . "/data");
$keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")));
$server = \Kelunik\AcmeClient\resolveServer($args->get("server"));
$keyFile = \Kelunik\AcmeClient\serverToKeyname($server);
@@ -33,7 +33,7 @@ class Revoke implements Command {
$this->climate->info("Revoking certificate ...");
$path = dirname(dirname(__DIR__)) . "/data/certs/" . $keyFile . "/" . $args->get("name") . "/cert.pem";
$path = \Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/certs/" . $keyFile . "/" . $args->get("name") . "/cert.pem";
try {
$pem = (yield \Amp\File\get($path));
@@ -50,15 +50,19 @@ class Revoke implements Command {
yield $acme->revokeCertificate($pem);
$this->climate->info("Certificate has been revoked.");
yield (new CertificateStore(dirname(dirname(__DIR__)) . "/data/certs/" . $keyFile))->delete($args->get("name"));
yield (new CertificateStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")). "/certs/" . $keyFile))->delete($args->get("name"));
return 0;
}
public static function getDefinition() {
$isPhar = \Kelunik\AcmeClient\isPhar();
return [
"server" => [
"prefix" => "s",
"longPrefix" => "server",
"description" => "",
"description" => "ACME server to use for registration and issuance of certificates.",
"required" => true,
],
"name" => [
@@ -66,6 +70,12 @@ class Revoke implements Command {
"description" => "Common name of the certificate to be revoked.",
"required" => true,
],
"storage" => [
"longPrefix" => "storage",
"description" => "Storage directory for account keys and certificates.",
"required" => $isPhar,
"defaultValue" => $isPhar ? null : (__DIR__ . "/../../data")
]
];
}
}