appwrite/src/Appwrite/Platform/Tasks/SSL.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2022-07-13 07:02:55 +00:00
<?php
2022-07-14 02:04:31 +00:00
2022-11-14 10:01:41 +00:00
namespace Appwrite\Platform\Tasks;
2022-07-13 07:02:55 +00:00
use Utopia\Platform\Action;
use Appwrite\Event\Certificate;
use Utopia\App;
use Utopia\CLI\Console;
use Utopia\Database\Document;
use Utopia\Validator\Hostname;
2022-07-14 02:04:31 +00:00
class SSL extends Action
{
2022-08-02 01:58:36 +00:00
public static function getName(): string
{
return 'ssl';
}
2022-07-14 02:04:31 +00:00
2022-07-13 07:02:55 +00:00
public function __construct()
{
$this
->desc('Validate server certificates')
->param('domain', App::getEnv('_APP_DOMAIN', ''), new Hostname(), 'Domain to generate certificate for. If empty, main domain will be used.', true)
2023-07-18 07:54:11 +00:00
->inject('queueForCertificates')
->callback(fn (string $domain, Certificate $queueForCertificates) => $this->action($domain, $queueForCertificates));
2022-07-13 07:02:55 +00:00
}
2023-07-18 07:54:11 +00:00
public function action(string $domain, Certificate $queueForCertificates): void
2022-07-13 07:02:55 +00:00
{
Console::success('Scheduling a job to issue a TLS certificate for domain: ' . $domain);
2023-07-18 07:54:11 +00:00
$queueForCertificates
2022-07-13 07:02:55 +00:00
->setDomain(new Document([
'domain' => $domain
]))
->setSkipRenewCheck(true)
->trigger();
}
2022-07-14 02:04:31 +00:00
}