diff --git a/modules/aggregator2/lib/EntitySource.php b/modules/aggregator2/lib/EntitySource.php
index f6e329290c9ea8486eb4f1999bb9c990207425a7..e849840ab641e9aad38a58f66d8182f0d9aea569 100644
--- a/modules/aggregator2/lib/EntitySource.php
+++ b/modules/aggregator2/lib/EntitySource.php
@@ -123,9 +123,8 @@ class sspmod_aggregator2_EntitySource {
 			$context['ssl']['CN_match'] = parse_url($this->url, PHP_URL_HOST);
 		}
 
-		$context = stream_context_create($context);
 
-		$data = file_get_contents($this->url, 0, $context);
+		$data = SimpleSAML_Utilities::fetch($this->url, $context);
 		if ($data === FALSE || $data === NULL) {
 			SimpleSAML_Logger::error($this->logLoc . 'Unable to load metadata from ' .
 				var_export($this->url, TRUE));