33 lines
1.0 KiB
PHP
33 lines
1.0 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use App\Services\TlsaService;
|
|
use Illuminate\Console\Command;
|
|
|
|
class TlsaRefresh extends Command
|
|
{
|
|
protected $signature = 'dns:tlsa:refresh';
|
|
protected $description = 'Aktualisiert TLSA (3 1 1) für den MX-Host (idempotent).';
|
|
|
|
public function handle(TlsaService $tlsa): int
|
|
{
|
|
if (app()->environment(['local', 'development'])) {
|
|
$this->info('TLSA: übersprungen in nicht-Produktivumgebung.');
|
|
return self::SUCCESS;
|
|
}
|
|
if (config('app.base_domain', env('BASE_DOMAIN', 'example.com')) === 'example.com') {
|
|
$this->info('TLSA: übersprungen für example.com.');
|
|
return self::SUCCESS;
|
|
}
|
|
|
|
$rec = $tlsa->refreshForMx();
|
|
if (!$rec) {
|
|
$this->warn('TLSA konnte nicht aktualisiert werden (Zertifikat fehlt?).');
|
|
return self::FAILURE;
|
|
}
|
|
$this->info("TLSA ok: {$rec->service}.{$rec->host} 3 1 1 {$rec->hash}");
|
|
return self::SUCCESS;
|
|
}
|
|
}
|