filters self-signed certs unless configured to

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/936/head
Maxence Lange 2020-07-07 10:25:50 -01:00
rodzic 98c0f9f9bd
commit 3b782315b9
2 zmienionych plików z 17 dodań i 3 usunięć

Wyświetl plik

@ -30,6 +30,7 @@ declare(strict_types=1);
namespace OCA\Social\Service;
use daita\MySmallPhpTools\Model\Request;
use daita\MySmallPhpTools\Traits\TArrayTools;
use daita\MySmallPhpTools\Traits\TPathTools;
use OCA\Social\AppInfo\Application;
@ -61,6 +62,8 @@ class ConfigService {
const SOCIAL_ACCESS_TYPE = 'access_type';
const SOCIAL_ACCESS_LIST = 'access_list';
const SOCIAL_SELF_SIGNED = 'allow_self_signed';
const BACKGROUND_CRON = 1;
const BACKGROUND_ASYNC = 2;
const BACKGROUND_SERVICE = 3;
@ -74,7 +77,8 @@ class ConfigService {
self::SOCIAL_SERVICE => 1,
self::SOCIAL_MAX_SIZE => 10,
self::SOCIAL_ACCESS_TYPE => 'all_but',
self::SOCIAL_ACCESS_LIST => '[]'
self::SOCIAL_ACCESS_LIST => '[]',
self::SOCIAL_SELF_SIGNED => '0'
];
/** @var array */
@ -428,5 +432,13 @@ class ConfigService {
}
/**
* @param Request $request
*/
public function configureRequest(Request $request) {
$request->setVerifyPeer($this->getAppValue(ConfigService::SOCIAL_SELF_SIGNED) !== '1');
}
}

Wyświetl plik

@ -252,8 +252,6 @@ class CurlService {
* @param Request $request
*
* @return array
* @throws SocialAppConfigException
* @throws UnauthorizedFediverseException
* @throws RequestContentException
* @throws RequestNetworkException
* @throws RequestResultNotJsonException
@ -261,6 +259,9 @@ class CurlService {
* @throws RequestServerException
*/
public function retrieveJson(Request $request): array {
$this->configService->configureRequest($request);
$this->assignUserAgent($request);
try {
$result = $this->retrieveJsonOrig($request);
} catch (RequestResultSizeException | RequestResultNotJsonException $e) {
@ -288,6 +289,7 @@ class CurlService {
*/
public function doRequest(Request $request) {
$this->fediverseService->authorized($request->getAddress());
$this->configService->configureRequest($request);
$this->assignUserAgent($request);
return $this->doRequestOrig($request);