1
0
Fork 0
mirror of synced 2024-06-02 10:54:44 +12:00

Updated challenge endpoint

This commit is contained in:
Eldad Fux 2020-02-23 10:55:57 +02:00
parent cefbc2fc4e
commit bf5d5f719e

View file

@ -364,27 +364,29 @@ $utopia->get('/.well-known/acme-challenge')
->label('docs', false)
->action(
function () use ($request, $response) {
$base = realpath(__DIR__.'/../certs');
$base = realpath(APP_STORAGE_CERTIFICATES);
$path = str_replace('/.well-known/acme-challenge/', '', $request->getParam('q'));
$absolute = realpath($base.'/'.$path);
$absolute = realpath($base.'/.well-known/acme-challenge/'.$path);
if(!$base) {
throw new Exception('Storage error', 500);
}
if(!$absolute) {
throw new Exception('Unknown Path', 404);
// $response->json([
// 'error' => 'unknown path',
// 'base' => scandir($base),
// 'base/well' => scandir($base . '/.well-known/'),
// 'base/well/acme' => scandir($base . '/.well-known/acme-challenge/'),
// 'base/well/acme/query' => ($absolute) ? scandir($absolute) : ['not-a-dir'],
// ]);
// return;
throw new Exception('Unknown path', 404);
}
if(!substr($absolute, 0, strlen($base)) === $base) {
throw new Exception('Invalid Path', 401);
throw new Exception('Invalid path', 401);
}
$response->text(file_get_contents($absolute));
$content = @file_get_contents($absolute);
if(!$content) {
throw new Exception('Failed to get contents', 500);
}
$response->text($content);
}
);