9 Commits

Author SHA1 Message Date
Niklas Keller
d4f2009315 Fix build on nightly 2018-01-11 17:18:29 +01:00
Niklas Keller
2b4a200263 Fix CSR generation 2018-01-11 17:15:04 +01:00
Niklas Keller
256aa76011 Fix directory permissions 2018-01-11 17:11:28 +01:00
Niklas Keller
69bc88daf1 Refactor directory creation 2018-01-11 17:00:27 +01:00
Niklas Keller
19f6550e33 Fix key store path in exception message 2018-01-11 16:53:01 +01:00
Niklas Keller
ed3da3c98d Fix DNS lookups 2018-01-11 16:43:32 +01:00
Niklas Keller
56955155fe Work around https://bugs.php.net/bug.php?id=75396 2018-01-11 10:36:45 +01:00
Niklas Keller
e3d7723da3 Fix bugs in stores not yielding the correct things 2018-01-11 10:32:17 +01:00
Niklas Keller
0ae207fce3 Downgrade dependencies to be compatible with PHP 7.0 2018-01-09 19:30:34 +01:00
8 changed files with 153 additions and 126 deletions

View File

@@ -20,7 +20,7 @@ install:
script:
- find -name "*.php" -not -path "./vendor/*" -print0 | xargs -n 1 -0 php -l
- phpdbg -qrr vendor/bin/phpunit --coverage-text --coverage-clover build/logs/clover.xml
- php vendor/bin/php-cs-fixer --diff --dry-run -v fix
- PHP_CS_FIXER_IGNORE_ENV=1 php vendor/bin/php-cs-fixer --diff --dry-run -v fix
after_script:
- php vendor/bin/coveralls -v

View File

@@ -144,8 +144,9 @@ $injector->share(new AcmeFactory);
$injector->share(new Amp\Artax\DefaultClient);
$command = $injector->make($class);
$exitCode = 1;
Loop::run(function () use ($command, $climate) {
Loop::run(function () use ($command, $climate, &$exitCode) {
$handler = function ($e) use ($climate) {
$error = (string) $e;
$lines = explode("\n", $error);
@@ -164,13 +165,13 @@ Loop::run(function () use ($command, $climate) {
$exitCode = yield $command->execute($climate->arguments);
if ($exitCode === null) {
exit(0);
$exitCode = 0;
}
exit($exitCode);
} catch (Throwable $e) {
$handler($e);
}
Loop::stop();
});
exit($exitCode);

View File

@@ -41,6 +41,11 @@
"src/functions.php"
]
},
"config": {
"platform": {
"php": "7.0.0"
}
},
"extra": {
"phar-builder": {
"compression": "GZip",

204
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
"content-hash": "f6204907e7e4526aabfcd45063dc0ff9",
"content-hash": "4332d77ce602e20b8ab72bdce75be8f8",
"packages": [
{
"name": "amphp/amp",
@@ -1283,26 +1283,23 @@
},
{
"name": "symfony/yaml",
"version": "v3.4.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "25c192f25721a74084272671f658797d9e0e0146"
"reference": "ddc23324e6cfe066f3dd34a37ff494fa80b617ed"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/25c192f25721a74084272671f658797d9e0e0146",
"reference": "25c192f25721a74084272671f658797d9e0e0146",
"url": "https://api.github.com/repos/symfony/yaml/zipball/ddc23324e6cfe066f3dd34a37ff494fa80b617ed",
"reference": "ddc23324e6cfe066f3dd34a37ff494fa80b617ed",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
},
"conflict": {
"symfony/console": "<3.4"
"php": ">=5.5.9"
},
"require-dev": {
"symfony/console": "~3.4|~4.0"
"symfony/console": "~2.8|~3.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
@@ -1310,7 +1307,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -1337,7 +1334,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00"
"time": "2017-07-23T12:43:26+00:00"
},
{
"name": "webmozart/assert",
@@ -1455,30 +1452,30 @@
},
{
"name": "doctrine/annotations",
"version": "v1.6.0",
"version": "v1.4.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/annotations.git",
"reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5"
"reference": "54cacc9b81758b14e3ce750f205a393d52339e97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5",
"reference": "c7f2050c68a9ab0bdb0f98567ec08d80ea7d24d5",
"url": "https://api.github.com/repos/doctrine/annotations/zipball/54cacc9b81758b14e3ce750f205a393d52339e97",
"reference": "54cacc9b81758b14e3ce750f205a393d52339e97",
"shasum": ""
},
"require": {
"doctrine/lexer": "1.*",
"php": "^7.1"
"php": "^5.6 || ^7.0"
},
"require-dev": {
"doctrine/cache": "1.*",
"phpunit/phpunit": "^6.4"
"phpunit/phpunit": "^5.7"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.6.x-dev"
"dev-master": "1.4.x-dev"
}
},
"autoload": {
@@ -1519,36 +1516,36 @@
"docblock",
"parser"
],
"time": "2017-12-06T07:11:42+00:00"
"time": "2017-02-24T16:22:25+00:00"
},
{
"name": "doctrine/instantiator",
"version": "1.1.0",
"version": "1.0.5",
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda"
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d",
"reference": "8e884e78f9f0eb1329e445619e04456e64d8051d",
"shasum": ""
},
"require": {
"php": "^7.1"
"php": ">=5.3,<8.0-DEV"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "^6.2.3",
"squizlabs/php_codesniffer": "^3.0.2"
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.2.x-dev"
"dev-master": "1.0.x-dev"
}
},
"autoload": {
@@ -1573,7 +1570,7 @@
"constructor",
"instantiate"
],
"time": "2017-07-22T11:58:36+00:00"
"time": "2015-06-14T21:17:01+00:00"
},
{
"name": "doctrine/lexer",
@@ -3465,45 +3462,45 @@
},
{
"name": "symfony/console",
"version": "v3.4.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d"
"reference": "b0878233cb5c4391347e5495089c7af11b8e6201"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"reference": "8394c8ef121949e8f858f13bc1e34f05169e4e7d",
"url": "https://api.github.com/repos/symfony/console/zipball/b0878233cb5c4391347e5495089c7af11b8e6201",
"reference": "b0878233cb5c4391347e5495089c7af11b8e6201",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8",
"symfony/debug": "~2.8|~3.0|~4.0",
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"conflict": {
"symfony/dependency-injection": "<3.4",
"symfony/process": "<3.3"
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.3|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/event-dispatcher": "~2.8|~3.0|~4.0",
"symfony/lock": "~3.4|~4.0",
"symfony/process": "~3.3|~4.0"
"symfony/config": "~3.3",
"symfony/dependency-injection": "~3.3",
"symfony/event-dispatcher": "~2.8|~3.0",
"symfony/filesystem": "~2.8|~3.0",
"symfony/http-kernel": "~2.8|~3.0",
"symfony/process": "~2.8|~3.0"
},
"suggest": {
"psr/log": "For using the console logger",
"symfony/event-dispatcher": "",
"symfony/lock": "",
"symfony/filesystem": "",
"symfony/process": ""
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -3530,36 +3527,36 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00"
"time": "2017-07-29T21:27:59+00:00"
},
{
"name": "symfony/debug",
"version": "v4.0.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "9ae4223a661b56a9abdce144de4886cca37f198f"
"reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/9ae4223a661b56a9abdce144de4886cca37f198f",
"reference": "9ae4223a661b56a9abdce144de4886cca37f198f",
"url": "https://api.github.com/repos/symfony/debug/zipball/7c13ae8ce1e2adbbd574fc39de7be498e1284e13",
"reference": "7c13ae8ce1e2adbbd574fc39de7be498e1284e13",
"shasum": ""
},
"require": {
"php": "^7.1.3",
"php": ">=5.5.9",
"psr/log": "~1.0"
},
"conflict": {
"symfony/http-kernel": "<3.4"
"symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2"
},
"require-dev": {
"symfony/http-kernel": "~3.4|~4.0"
"symfony/http-kernel": "~2.8|~3.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -3586,34 +3583,34 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T17:15:19+00:00"
"time": "2017-07-28T15:27:31+00:00"
},
{
"name": "symfony/event-dispatcher",
"version": "v4.0.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb"
"reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/74d33aac36208c4d6757807d9f598f0133a3a4eb",
"reference": "74d33aac36208c4d6757807d9f598f0133a3a4eb",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/67535f1e3fd662bdc68d7ba317c93eecd973617e",
"reference": "67535f1e3fd662bdc68d7ba317c93eecd973617e",
"shasum": ""
},
"require": {
"php": "^7.1.3"
"php": ">=5.5.9"
},
"conflict": {
"symfony/dependency-injection": "<3.4"
"symfony/dependency-injection": "<3.3"
},
"require-dev": {
"psr/log": "~1.0",
"symfony/config": "~3.4|~4.0",
"symfony/dependency-injection": "~3.4|~4.0",
"symfony/expression-language": "~3.4|~4.0",
"symfony/stopwatch": "~3.4|~4.0"
"symfony/config": "~2.8|~3.0",
"symfony/dependency-injection": "~3.3",
"symfony/expression-language": "~2.8|~3.0",
"symfony/stopwatch": "~2.8|~3.0"
},
"suggest": {
"symfony/dependency-injection": "",
@@ -3622,7 +3619,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -3649,29 +3646,29 @@
],
"description": "Symfony EventDispatcher Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:38:00+00:00"
"time": "2017-06-09T14:53:08+00:00"
},
{
"name": "symfony/filesystem",
"version": "v4.0.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/filesystem.git",
"reference": "760e47a4ee64b4c48f4b30017011e09d4c0f05ed"
"reference": "427987eb4eed764c3b6e38d52a0f87989e010676"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/760e47a4ee64b4c48f4b30017011e09d4c0f05ed",
"reference": "760e47a4ee64b4c48f4b30017011e09d4c0f05ed",
"url": "https://api.github.com/repos/symfony/filesystem/zipball/427987eb4eed764c3b6e38d52a0f87989e010676",
"reference": "427987eb4eed764c3b6e38d52a0f87989e010676",
"shasum": ""
},
"require": {
"php": "^7.1.3"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -3698,29 +3695,29 @@
],
"description": "Symfony Filesystem Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:38:00+00:00"
"time": "2017-07-11T07:17:58+00:00"
},
{
"name": "symfony/finder",
"version": "v3.4.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f"
"reference": "baea7f66d30854ad32988c11a09d7ffd485810c4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/613e26310776f49a1773b6737c6bd554b8bc8c6f",
"reference": "613e26310776f49a1773b6737c6bd554b8bc8c6f",
"url": "https://api.github.com/repos/symfony/finder/zipball/baea7f66d30854ad32988c11a09d7ffd485810c4",
"reference": "baea7f66d30854ad32988c11a09d7ffd485810c4",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -3747,29 +3744,29 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00"
"time": "2017-06-01T21:01:25+00:00"
},
{
"name": "symfony/options-resolver",
"version": "v4.0.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/options-resolver.git",
"reference": "30d9240b30696a69e893534c9fc4a5c72ab6689b"
"reference": "ff48982d295bcac1fd861f934f041ebc73ae40f0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/30d9240b30696a69e893534c9fc4a5c72ab6689b",
"reference": "30d9240b30696a69e893534c9fc4a5c72ab6689b",
"url": "https://api.github.com/repos/symfony/options-resolver/zipball/ff48982d295bcac1fd861f934f041ebc73ae40f0",
"reference": "ff48982d295bcac1fd861f934f041ebc73ae40f0",
"shasum": ""
},
"require": {
"php": "^7.1.3"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -3801,7 +3798,7 @@
"configuration",
"options"
],
"time": "2018-01-03T07:38:00+00:00"
"time": "2017-04-12T14:14:56+00:00"
},
{
"name": "symfony/polyfill-mbstring",
@@ -3978,25 +3975,25 @@
},
{
"name": "symfony/process",
"version": "v3.4.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba"
"reference": "07432804942b9f6dd7b7377faf9920af5f95d70a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/ff69f110c6b33fd33cd2089ba97d6112f44ef0ba",
"reference": "ff69f110c6b33fd33cd2089ba97d6112f44ef0ba",
"url": "https://api.github.com/repos/symfony/process/zipball/07432804942b9f6dd7b7377faf9920af5f95d70a",
"reference": "07432804942b9f6dd7b7377faf9920af5f95d70a",
"shasum": ""
},
"require": {
"php": "^5.5.9|>=7.0.8"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.4-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -4023,29 +4020,29 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:37:34+00:00"
"time": "2017-07-13T13:05:09+00:00"
},
{
"name": "symfony/stopwatch",
"version": "v4.0.3",
"version": "v3.3.6",
"source": {
"type": "git",
"url": "https://github.com/symfony/stopwatch.git",
"reference": "d52321f0e2b596bd03b5d1dd6eebe71caa925704"
"reference": "602a15299dc01556013b07167d4f5d3a60e90d15"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/d52321f0e2b596bd03b5d1dd6eebe71caa925704",
"reference": "d52321f0e2b596bd03b5d1dd6eebe71caa925704",
"url": "https://api.github.com/repos/symfony/stopwatch/zipball/602a15299dc01556013b07167d4f5d3a60e90d15",
"reference": "602a15299dc01556013b07167d4f5d3a60e90d15",
"shasum": ""
},
"require": {
"php": "^7.1.3"
"php": ">=5.5.9"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "4.0-dev"
"dev-master": "3.3-dev"
}
},
"autoload": {
@@ -4072,7 +4069,7 @@
],
"description": "Symfony Stopwatch Component",
"homepage": "https://symfony.com",
"time": "2018-01-03T07:38:00+00:00"
"time": "2017-04-12T14:14:56+00:00"
},
{
"name": "theseer/tokenizer",
@@ -4167,5 +4164,8 @@
"php": ">=7",
"ext-openssl": "*"
},
"platform-dev": []
"platform-dev": [],
"platform-overrides": {
"php": "7.0.0"
}
}

View File

@@ -2,6 +2,7 @@
namespace Kelunik\AcmeClient\Commands;
use Amp\Dns;
use Amp\Promise;
use Kelunik\Acme\AcmeException;
use Kelunik\Acme\AcmeService;
@@ -109,7 +110,7 @@ class Issue implements Command {
$this->climate->br();
$this->climate->whisper(' Requesting certificate ...');
$csr = (new OpensslCsrGenerator)->generateCsr($key, $domains);
$csr = yield (new OpensslCsrGenerator)->generateCsr($key, $domains);
$location = yield $acme->requestCertificate($csr);
$certificates = yield $acme->pollForCertificate($location);
@@ -161,7 +162,10 @@ class Issue implements Command {
}
private function checkDnsRecords(array $domains): \Generator {
$promises = AcmeClient\concurrentMap(10, \array_combine($domains, $domains), 'Amp\Dns\resolve');
$promises = AcmeClient\concurrentMap(10, $domains, function (string $domain): Promise {
return Dns\resolve($domain);
});
list($errors) = yield Promise\any($promises);
if ($errors) {

View File

@@ -47,8 +47,12 @@ class CertificateStore {
$chain = \array_slice($certificates, 1);
$path = $this->root . '/' . $commonName;
if (!yield File\isdir($path) && !yield File\mkdir($path, 0644, true) && !yield File\isdir($path)) {
throw new FilesystemException("Couldn't create certificate directory: '{$path}'");
if (!yield File\isdir($path)) {
yield File\mkdir($path, 0755, true);
if (!yield File\isdir($path)) {
throw new FilesystemException("Couldn't create certificate directory: '{$path}'");
}
}
yield File\put($path . '/cert.pem', $certificates[0]);

View File

@@ -22,8 +22,12 @@ class ChallengeStore {
throw new ChallengeStoreException("Document root doesn't exist: '{$this->docroot}'");
}
if (!yield File\isdir($path) && !yield File\mkdir($path, 0644, true) && !yield File\isdir($path)) {
throw new ChallengeStoreException("Couldn't create key directory: '{$path}'");
if (!yield File\isdir($path)) {
yield File\mkdir($path, 0755, true);
if (!yield File\isdir($path)) {
throw new ChallengeStoreException("Couldn't create key directory: '{$path}'");
}
}
if ($user && !$userInfo = \posix_getpwnam($user)) {
@@ -35,13 +39,13 @@ class ChallengeStore {
yield File\chown($this->docroot . '/.well-known/acme-challenge', $userInfo['uid'], -1);
}
yield \Amp\File\put("{$path}/{$token}", $payload);
yield File\put("{$path}/{$token}", $payload);
if ($userInfo !== null) {
yield \Amp\File\chown("{$path}/{$token}", $userInfo['uid'], -1);
yield File\chown("{$path}/{$token}", $userInfo['uid'], -1);
}
yield \Amp\File\chmod("{$path}/{$token}", 0644);
yield File\chmod("{$path}/{$token}", 0644);
});
}
@@ -50,7 +54,7 @@ class ChallengeStore {
$path = $this->docroot . "/.well-known/acme-challenge/{$token}";
if (yield File\exists($path)) {
yield \Amp\File\unlink($path);
yield File\unlink($path);
}
});
}

View File

@@ -18,16 +18,21 @@ class KeyStore {
public function get(string $path): Promise {
return call(function () use ($path) {
$file = $this->root . '/' . $path;
$privateKey = yield File\get($file);
// Check key here to be valid, PrivateKey doesn't do that, we fail early here
$res = \openssl_pkey_get_private($privateKey);
try {
$privateKey = yield File\get($file);
if ($res === false) {
throw new KeyStoreException("Invalid private key: '{$file}'");
// Check key here to be valid, PrivateKey doesn't do that, we fail early here
$res = \openssl_pkey_get_private($privateKey);
if ($res === false) {
throw new KeyStoreException("Invalid private key: '{$file}'");
}
return new PrivateKey($privateKey);
} catch (FilesystemException $e) {
throw new KeyStoreException("Key not found: '{$file}'");
}
return new PrivateKey($privateKey);
});
}
@@ -38,8 +43,12 @@ class KeyStore {
try {
$dir = \dirname($file);
if (!yield File\isdir($dir) && !yield File\mkdir($dir, 0644, true) && !yield File\isdir($dir)) {
throw new FilesystemException("Couldn't create key directory: '{$path}'");
if (!yield File\isdir($dir)) {
yield File\mkdir($dir, 0755, true);
if (!yield File\isdir($dir)) {
throw new FilesystemException("Couldn't create key directory: '{$dir}'");
}
}
yield File\put($file, $key->toPem());