Ensure consistent server and storage arguments, fix storage path for setup
This commit is contained in:
@@ -23,7 +23,7 @@
|
|||||||
"require-dev": {
|
"require-dev": {
|
||||||
"phpunit/phpunit": "^5",
|
"phpunit/phpunit": "^5",
|
||||||
"fabpot/php-cs-fixer": "^1.9",
|
"fabpot/php-cs-fixer": "^1.9",
|
||||||
"macfja/phar-builder": "^0.2.3"
|
"macfja/phar-builder": "dev-master#bf48160bd6bdf702557ff213e6837710c1dbf572"
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"authors": [
|
"authors": [
|
||||||
@@ -47,7 +47,7 @@
|
|||||||
"compression": "GZip",
|
"compression": "GZip",
|
||||||
"name": "acme.phar",
|
"name": "acme.phar",
|
||||||
"output-dir": "build",
|
"output-dir": "build",
|
||||||
"include": ["bin", "src", "vendor"],
|
"include": ["src"],
|
||||||
"entry-point": "bin/acme"
|
"entry-point": "bin/acme"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,15 +44,9 @@ class Check implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefinition() {
|
public static function getDefinition() {
|
||||||
$isPhar = \Kelunik\AcmeClient\isPhar();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"server" => [
|
"server" => \Kelunik\AcmeClient\getArgumentDescription("server"),
|
||||||
"prefix" => "s",
|
"storage" => \Kelunik\AcmeClient\getArgumentDescription("storage"),
|
||||||
"longPrefix" => "server",
|
|
||||||
"description" => "ACME server to use for registration and issuance of certificates.",
|
|
||||||
"required" => true,
|
|
||||||
],
|
|
||||||
"name" => [
|
"name" => [
|
||||||
"longPrefix" => "name",
|
"longPrefix" => "name",
|
||||||
"description" => "Common name of the certificate to check.",
|
"description" => "Common name of the certificate to check.",
|
||||||
@@ -64,12 +58,6 @@ class Check implements Command {
|
|||||||
"defaultValue" => 30,
|
"defaultValue" => 30,
|
||||||
"castTo" => "int",
|
"castTo" => "int",
|
||||||
],
|
],
|
||||||
"storage" => [
|
|
||||||
"longPrefix" => "storage",
|
|
||||||
"description" => "Storage directory for account keys and certificates.",
|
|
||||||
"required" => $isPhar,
|
|
||||||
"defaultValue" => $isPhar ? null : (__DIR__ . "/../../data")
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -196,15 +196,9 @@ class Issue implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefinition() {
|
public static function getDefinition() {
|
||||||
$isPhar = \Kelunik\AcmeClient\isPhar();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"server" => [
|
"server" => \Kelunik\AcmeClient\getArgumentDescription("server"),
|
||||||
"prefix" => "s",
|
"storage" => \Kelunik\AcmeClient\getArgumentDescription("storage"),
|
||||||
"longPrefix" => "server",
|
|
||||||
"description" => "ACME server to use for registration and issuance of certificates.",
|
|
||||||
"required" => true,
|
|
||||||
],
|
|
||||||
"domains" => [
|
"domains" => [
|
||||||
"prefix" => "d",
|
"prefix" => "d",
|
||||||
"longPrefix" => "domains",
|
"longPrefix" => "domains",
|
||||||
@@ -228,12 +222,6 @@ class Issue implements Command {
|
|||||||
"defaultValue" => 2048,
|
"defaultValue" => 2048,
|
||||||
"castTo" => "int",
|
"castTo" => "int",
|
||||||
],
|
],
|
||||||
"storage" => [
|
|
||||||
"longPrefix" => "storage",
|
|
||||||
"description" => "Storage directory for account keys and certificates.",
|
|
||||||
"required" => $isPhar,
|
|
||||||
"defaultValue" => $isPhar ? null : (__DIR__ . "/../../data")
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,26 +56,14 @@ class Revoke implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefinition() {
|
public static function getDefinition() {
|
||||||
$isPhar = \Kelunik\AcmeClient\isPhar();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"server" => [
|
"server" => \Kelunik\AcmeClient\getArgumentDescription("server"),
|
||||||
"prefix" => "s",
|
"storage" => \Kelunik\AcmeClient\getArgumentDescription("storage"),
|
||||||
"longPrefix" => "server",
|
|
||||||
"description" => "ACME server to use for registration and issuance of certificates.",
|
|
||||||
"required" => true,
|
|
||||||
],
|
|
||||||
"name" => [
|
"name" => [
|
||||||
"longPrefix" => "name",
|
"longPrefix" => "name",
|
||||||
"description" => "Common name of the certificate to be revoked.",
|
"description" => "Common name of the certificate to be revoked.",
|
||||||
"required" => true,
|
"required" => true,
|
||||||
],
|
],
|
||||||
"storage" => [
|
|
||||||
"longPrefix" => "storage",
|
|
||||||
"description" => "Storage directory for account keys and certificates.",
|
|
||||||
"required" => $isPhar,
|
|
||||||
"defaultValue" => $isPhar ? null : (__DIR__ . "/../../data")
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,7 +36,7 @@ class Setup implements Command {
|
|||||||
$path = "accounts/{$keyFile}.pem";
|
$path = "accounts/{$keyFile}.pem";
|
||||||
$bits = 4096;
|
$bits = 4096;
|
||||||
|
|
||||||
$keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")) . "/data");
|
$keyStore = new KeyStore(\Kelunik\AcmeClient\normalizePath($args->get("storage")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$keyPair = (yield $keyStore->get($path));
|
$keyPair = (yield $keyStore->get($path));
|
||||||
@@ -78,26 +78,16 @@ class Setup implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static function getDefinition() {
|
public static function getDefinition() {
|
||||||
$isPhar = \Kelunik\AcmeClient\isPhar();
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"server" => [
|
"server" => \Kelunik\AcmeClient\getArgumentDescription("server"),
|
||||||
"prefix" => "s",
|
"storage" => \Kelunik\AcmeClient\getArgumentDescription("storage"),
|
||||||
"longPrefix" => "server",
|
|
||||||
"description" => "ACME server to use for registration and issuance of certificates.",
|
|
||||||
"required" => true,
|
|
||||||
],
|
|
||||||
"email" => [
|
"email" => [
|
||||||
"longPrefix" => "email",
|
"longPrefix" => "email",
|
||||||
"description" => "E-mail for important issues, will be sent to the ACME server.",
|
"description" => "E-mail for important issues, will be sent to the ACME server.",
|
||||||
"required" => true,
|
"required" => true,
|
||||||
],
|
],
|
||||||
"storage" => [
|
|
||||||
"longPrefix" => "storage",
|
|
||||||
"description" => "Storage directory for account keys and certificates.",
|
|
||||||
"required" => $isPhar,
|
|
||||||
"defaultValue" => $isPhar ? null : (__DIR__ . "/../../data")
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -69,4 +69,34 @@ function isPhar() {
|
|||||||
|
|
||||||
function normalizePath($path) {
|
function normalizePath($path) {
|
||||||
return rtrim(str_replace("\\", "/", $path), "/");
|
return rtrim(str_replace("\\", "/", $path), "/");
|
||||||
|
}
|
||||||
|
|
||||||
|
function getArgumentDescription($argument) {
|
||||||
|
$isPhar = \Kelunik\AcmeClient\isPhar();
|
||||||
|
|
||||||
|
switch ($argument) {
|
||||||
|
case "server":
|
||||||
|
return [
|
||||||
|
"prefix" => "s",
|
||||||
|
"longPrefix" => "server",
|
||||||
|
"description" => "ACME server to use for registration and issuance of certificates.",
|
||||||
|
"required" => true,
|
||||||
|
];
|
||||||
|
|
||||||
|
case "storage":
|
||||||
|
$argument = [
|
||||||
|
"longPrefix" => "storage",
|
||||||
|
"description" => "Storage directory for account keys and certificates.",
|
||||||
|
"required" => $isPhar,
|
||||||
|
];
|
||||||
|
|
||||||
|
if (!$isPhar) {
|
||||||
|
$argument["defaultValue"] = dirname(__DIR__) . "/data";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $argument;
|
||||||
|
|
||||||
|
default:
|
||||||
|
throw new \InvalidArgumentException("Unknown argument: " . $argument);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user