1
0
Fork 0
mirror of synced 2024-07-01 04:30:59 +12:00

certbot tests

This commit is contained in:
Eldad Fux 2020-02-19 08:37:02 +02:00
parent 93ff9a0c04
commit 009a24189b

View file

@ -367,14 +367,29 @@ $utopia->get('/.well-known/acme-challenge')
$base = realpath(__DIR__.'/../certs');
$path = str_replace('/.well-known/acme-challenge/', '', $request->getParam('q'));
$absolute = realpath($base.'/'.$path);
return $response->json($files1 = scandir($base));
if(!$absolute) {
throw new Exception('Unknown Path', 404);
//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;
}
if(!substr($absolute, 0, strlen($base)) === $base) {
throw new Exception('Invalid Path', 401);
//throw new Exception('Invalid Path', 401);
$response->json([
'error' => 'invalid 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;
}
$response->text(file_get_contents($absolute));