Skip to content

Commit

Permalink
Prepare installer
Browse files Browse the repository at this point in the history
-------------------

- Allow to turn off host and peer verification via debug mode, for local development environments
  • Loading branch information
doishub committed Oct 5, 2023
1 parent ec2e057 commit a376048
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/Controller/API/ContaoManager/ContaoManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Contao\Environment;
use Contao\System;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Exception;
use Oveleon\ProductInstaller\ContaoManagerFile;
use Symfony\Component\HttpClient\HttpClient;
Expand Down Expand Up @@ -85,9 +84,10 @@ public function call(string $route, string $method = 'GET', null|string $body =
$parameter['body'] = $body;
}

// ToDo: Remove in production
#$parameter['verify_peer'] = false;
#$parameter['verify_host'] = false;
$blnDebug = System::getContainer()->getParameter('kernel.debug');

$parameter['verify_peer'] = !$blnDebug;
$parameter['verify_host'] = !$blnDebug;

return (HttpClient::create())->request(
$method,
Expand Down
7 changes: 5 additions & 2 deletions src/Util/ConnectorUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Oveleon\ProductInstaller\Util;

use Contao\Controller;
use Contao\System;
use Oveleon\ProductInstaller\LicenseConnector\AbstractLicenseConnector;
use Oveleon\ProductInstaller\LicenseConnector\Step\AbstractStep;
use Symfony\Contracts\HttpClient\ResponseInterface;
Expand All @@ -20,12 +21,14 @@ class ConnectorUtil
*/
public function post(AbstractLicenseConnector $connector, string $route, array $body = []): ResponseInterface
{
$blnDebug = System::getContainer()->getParameter('kernel.debug');

return (HttpClient::create())->request(
'POST',
$connector->getConfig()['entry'] . $route,
[
//'verify_peer' => false, // ToDO: Remove in production
//'verify_host' => false, // ToDO: Remove in production
'verify_peer' => !$blnDebug,
'verify_host' => !$blnDebug,
'headers' => [
'Content-Type' => 'application/json',
'Cache-Control' => 'no-cache'
Expand Down

0 comments on commit a376048

Please sign in to comment.