download = $download ?? new Download(5, 10); } public function token(): string { return hash_hmac('sha256', 'site-origin', $this->secret); } /** Null, wenn die Adresse hier ankommt - sonst der Grund in einem Satz. */ public function problem(string $origin): ?string { if (!str_starts_with($origin, 'https://')) { return 'Geprüft werden nur HTTPS-Adressen. Eine Adresse mit http:// lässt sich nur mit „Trotzdem übernehmen“ speichern.'; } $antwort = $this->download->get($origin.self::PATH); if (null === $antwort) { $grund = $this->download->reason(); return 'Unter '.$origin.' antwortet diese Website nicht'.('' !== $grund ? ': '.rtrim($grund, '.').'.' : '.').' DNS-Eintrag und Zertifikat für diese Domain prüfen.'; } if (!hash_equals($this->token(), trim($antwort))) { return 'Unter '.$origin.' antwortet eine andere Website. Zeigt die Domain auf diesen Server?'; } return null; } }