poc certificate auto generation
This commit is contained in:
parent
a512edf7c3
commit
0c3bcb40a4
32
app/http.php
32
app/http.php
|
@ -12,6 +12,7 @@ use Swoole\Http\Request as SwooleRequest;
|
|||
use Swoole\Http\Response as SwooleResponse;
|
||||
use Utopia\App;
|
||||
use Utopia\CLI\Console;
|
||||
use Utopia\Config\Config;
|
||||
|
||||
// xdebug_start_trace('/tmp/trace');
|
||||
|
||||
|
@ -65,22 +66,35 @@ Files::load(__DIR__ . '/../public');
|
|||
|
||||
include __DIR__ . '/controllers/general.php';
|
||||
|
||||
$domain = App::getEnv('_APP_DOMAIN', '');
|
||||
function certificateSetup($domain)
|
||||
{
|
||||
$domains = Config::getParam('domains', []);
|
||||
if (!in_array($domain, $domains)) {
|
||||
//schedule
|
||||
Console::info('adding ' . $domain . ' to list of domains already checked');
|
||||
array_push($domains, $domain);
|
||||
Config::setParam('domains', $domains);
|
||||
|
||||
Console::info('Issuing a TLS certificate for the master domain ('.$domain.') in 30 seconds.
|
||||
Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script
|
||||
Console::info('Issuing a TLS certificate for the master domain (' . $domain . ') in 30 seconds.
|
||||
Make sure your domain points to your server IP or restart your Appwrite server to try again.'); // TODO move this to installation script
|
||||
|
||||
ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [
|
||||
'document' => [],
|
||||
'domain' => $domain,
|
||||
'validateTarget' => false,
|
||||
'validateCNAME' => false,
|
||||
]);
|
||||
ResqueScheduler::enqueueAt(\time() + 30, 'v1-certificates', 'CertificatesV1', [
|
||||
'document' => [],
|
||||
'domain' => $domain,
|
||||
'validateTarget' => false,
|
||||
'validateCNAME' => false,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$http->on('request', function (SwooleRequest $swooleRequest, SwooleResponse $swooleResponse) {
|
||||
$request = new Request($swooleRequest);
|
||||
$response = new Response($swooleResponse);
|
||||
|
||||
$domain = $request->getHostname();
|
||||
certificateSetup($domain);
|
||||
|
||||
if(Files::isFileLoaded($request->getURI())) {
|
||||
$time = (60 * 60 * 24 * 365 * 2); // 45 days cache
|
||||
|
||||
|
|
Loading…
Reference in a new issue