Deploy Ladill Hosting / deploy (push) Successful in 58s
Push the customer's connected domain to the central connected-domains registry so it appears under My Domains (with Transfer in if not registered with Ladill). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
57 lines
2.1 KiB
PHP
57 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Ssl;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
/**
|
|
* Reports certificates this app issued (per hosting node) to Ladill Domains'
|
|
* central SSL registry, so Domains is the single source of truth for every
|
|
* platform certificate. Best-effort and non-blocking — issuance stays local.
|
|
*/
|
|
class CentralSslRegistry
|
|
{
|
|
public function register(string $host, ?\DateTimeInterface $expiresAt = null): void
|
|
{
|
|
$url = rtrim((string) config('domains.api_url'), '/');
|
|
$key = (string) config('domains.api_key');
|
|
if ($url === '' || $key === '' || $host === '') {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
Http::withToken($key)->acceptJson()->timeout(10)
|
|
->post($url.'/ssl/register', array_filter([
|
|
'host' => $host,
|
|
'status' => 'active',
|
|
'expires_at' => $expiresAt?->format(DATE_ATOM),
|
|
]));
|
|
} catch (\Throwable $e) {
|
|
Log::info('CentralSslRegistry: register skipped', ['host' => $host, 'error' => $e->getMessage()]);
|
|
}
|
|
}
|
|
|
|
/** Surface a hosted-site domain in Ladill Domains' "My Domains" (best-effort). */
|
|
public function registerConnectedDomain(string $host, string $ownerPublicId, ?string $label = null, ?string $linkUrl = null): void
|
|
{
|
|
$url = rtrim((string) config('domains.api_url'), '/');
|
|
$key = (string) config('domains.api_key');
|
|
if ($url === '' || $key === '' || $host === '' || $ownerPublicId === '') {
|
|
return;
|
|
}
|
|
|
|
try {
|
|
Http::withToken($key)->acceptJson()->timeout(10)
|
|
->post($url.'/connected-domains', array_filter([
|
|
'host' => $host,
|
|
'owner_public_id' => $ownerPublicId,
|
|
'label' => $label,
|
|
'link_url' => $linkUrl,
|
|
]));
|
|
} catch (\Throwable $e) {
|
|
Log::info('CentralSslRegistry: connected register skipped', ['host' => $host, 'error' => $e->getMessage()]);
|
|
}
|
|
}
|
|
}
|