Fix bugs in stores not yielding the correct things
This commit is contained in:
@@ -47,7 +47,7 @@ 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)) {
|
||||
if (!(yield File\isdir($path)) && !(yield File\mkdir($path, 0644, true)) && !(yield File\isdir($path))) {
|
||||
throw new FilesystemException("Couldn't create certificate directory: '{$path}'");
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ 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)) {
|
||||
if (!(yield File\isdir($path)) && !(yield File\mkdir($path, 0644, true)) && !(yield File\isdir($path))) {
|
||||
throw new ChallengeStoreException("Couldn't create key directory: '{$path}'");
|
||||
}
|
||||
|
||||
@@ -35,13 +35,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 +50,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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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,7 +43,7 @@ class KeyStore {
|
||||
try {
|
||||
$dir = \dirname($file);
|
||||
|
||||
if (!yield File\isdir($dir) && !yield File\mkdir($dir, 0644, true) && !yield File\isdir($dir)) {
|
||||
if (!(yield File\isdir($dir)) && !(yield File\mkdir($dir, 0644, true)) && !(yield File\isdir($dir))) {
|
||||
throw new FilesystemException("Couldn't create key directory: '{$path}'");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user