update rm deadcode
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Support;
|
||||
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
final class TlsHttpClientFactory
|
||||
{
|
||||
public static function vCenter(): PendingRequest
|
||||
{
|
||||
return Http::withOptions(['verify' => self::verifyOption('vmware')]);
|
||||
}
|
||||
|
||||
public static function plesk(): PendingRequest
|
||||
{
|
||||
return Http::withOptions(['verify' => self::verifyOption('services.plesk')]);
|
||||
}
|
||||
|
||||
/** @return array<int, mixed> */
|
||||
public static function vCenterCurlOptions(): array
|
||||
{
|
||||
$verify = self::verifyOption('vmware');
|
||||
|
||||
return array_filter([
|
||||
CURLOPT_SSL_VERIFYPEER => $verify !== false,
|
||||
CURLOPT_SSL_VERIFYHOST => $verify === false ? 0 : 2,
|
||||
CURLOPT_CAINFO => is_string($verify) ? $verify : null,
|
||||
], fn ($value) => $value !== null);
|
||||
}
|
||||
|
||||
private static function verifyOption(string $configKey): bool|string
|
||||
{
|
||||
if (!config("{$configKey}.tls_verify", true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return config("{$configKey}.ca_bundle") ?: true;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user