Skip to content

Commit 71f97bd

Browse files
committed
Replace download with symfony http-client
See: https://symfony.com/doc/current/http_client.html#https-certificate
1 parent 27f256f commit 71f97bd

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/Controller/Aggregator.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ class Aggregator
3737
'application/xml',
3838
];
3939

40+
4041
/**
4142
* Controller constructor.
4243
*

src/EntitySource.php

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,23 +134,18 @@ private function downloadMetadata(): EntitiesDescriptor|EntityDescriptor|null
134134
Logger::debug($this->logLoc . 'Downloading metadata from ' . var_export($this->url, true));
135135
$configUtils = new Utils\Config();
136136

137-
$context = ['ssl' => []];
138-
if ($this->sslCAFile !== null) {
139-
$context['ssl']['cafile'] = $configUtils->getCertPath($this->sslCAFile);
140-
Logger::debug(
141-
$this->logLoc . 'Validating https connection against CA certificate(s) found in ' .
142-
var_export($context['ssl']['cafile'], true),
143-
);
144-
$context['ssl']['verify_peer'] = true;
145-
$context['ssl']['CN_match'] = parse_url($this->url, PHP_URL_HOST);
146-
}
137+
$httpUtils = new Utils\HTTP();
138+
$client = $httpUtils->createHttpClient();
139+
$response = $client->request('GET', $this->url);
147140

148141
try {
149-
$httpUtils = new Utils\HTTP();
150-
$data = $httpUtils->fetch($this->url, $context, false);
151-
} catch (Error\Exception $e) {
152-
Logger::error($this->logLoc . 'Unable to load metadata from ' . var_export($this->url, true));
142+
// Trigger any issues that may occur during transport
143+
$statusCode = $response->getStatusCode();
144+
} catch (TransportException $e) {
145+
Logger::error('Unable to load metadata from ' . var_export($this->url, true));
153146
return null;
147+
} finally {
148+
$data = $response->getContent();
154149
}
155150

156151
$doc = DOMDocumentFactory::create();

0 commit comments

Comments
 (0)