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

39 lines
984 B
PHP
Raw Normal View History

2022-07-13 07:02:55 +00:00
<?php
2022-07-14 02:04:31 +00:00
2022-08-02 01:32:46 +00:00
namespace Appwrite\CLI\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)
->callback(fn ($domain) => $this->action($domain));
}
public function action(string $domain): void
{
Console::success('Scheduling a job to issue a TLS certificate for domain: ' . $domain);
(new Certificate())
->setDomain(new Document([
'domain' => $domain
]))
->setSkipRenewCheck(true)
->trigger();
}
2022-07-14 02:04:31 +00:00
}