3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-02-06 17:45:52 +00:00

Improve .env file checking to not validate SSL certificates

This commit is contained in:
Brady Wetherington
2024-07-23 16:03:02 +01:00
parent 30835fe9ba
commit 5eea08088d
2 changed files with 11 additions and 4 deletions

View File

@ -14,7 +14,6 @@ use App\Models\Asset;
use App\Models\User;
use App\Notifications\FirstAdminNotification;
use App\Notifications\MailTest;
use Illuminate\Http\Client\HttpClientException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Storage;
@ -129,12 +128,12 @@ class SettingsController extends Controller
protected function dotEnvFileIsExposed() : bool
{
try {
return Http::timeout(10)
return Http::withoutVerifying()->timeout(10)
->accept('*/*')
->get(URL::to('.env'))
->successful();
} catch (HttpClientException $e) {
Log::debug($e->getMessage());
} catch (\Exception $e) {
Log::error($e->getMessage());
return true;
}
}

View File

@ -2,6 +2,7 @@
namespace Tests\Feature\Settings;
use App\Http\Controllers\SettingsController;
use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\Request;
@ -301,4 +302,11 @@ class ShowSetUpPageTest extends TestCase
$this->assertSeeDirectoryPermissionError(false);
}
public function testInvalidTLSCertsOkWhenCheckingForEnvFile()
{
//set the weird bad SSL cert place - https://self-signed.badssl.com
$this->assertTrue((new SettingsController())->dotEnvFileIsExposed());
}
}