diff --git a/lib/SimpleSAML/Metadata/SAMLParser.php b/lib/SimpleSAML/Metadata/SAMLParser.php
index 3981c865bb09ed255662b3a8012408c9703f9206..fdd8fd5b3e10625dd890e9e93bf12241178577e9 100644
--- a/lib/SimpleSAML/Metadata/SAMLParser.php
+++ b/lib/SimpleSAML/Metadata/SAMLParser.php
@@ -598,13 +598,9 @@ class SimpleSAML_Metadata_SAMLParser {
 			$ret['NameIDFormat'] = $spd['nameIDFormats'][0];
 		}
 
-		// Require that a certificate is embedded
-		if (!is_array($idp['keys'])) {
-			throw new Exception('Could not find any embedded certificates in metadata document.');
-		}
 
 		/* Add certificate data. Only the first valid certificate will be added. */
-		foreach($idp['keys'] as $key) {
+		foreach($spd['keys'] as $key) {
 			if($key['type'] !== 'X509Certificate') {
 				continue;
 			}
@@ -623,6 +619,8 @@ class SimpleSAML_Metadata_SAMLParser {
 		/* Add organization info. */
 		$this->addOrganizationInfo($ret);
 
+		
+
 		return $ret;
 	}
 
diff --git a/modules/aggregator/www/index.php b/modules/aggregator/www/index.php
index fe5cd0cb2c8b0106def8e33a5f8805bc01dd7f89..3afe2d0ff8726ca9449dbef4b186e75781f98d4d 100644
--- a/modules/aggregator/www/index.php
+++ b/modules/aggregator/www/index.php
@@ -59,6 +59,9 @@ foreach ($sources as $source) {
 	}
 }
 
+
+
+
 $xml = new DOMDocument();
 $entitiesDescriptor = $xml->createElementNS('urn:oasis:names:tc:SAML:2.0:metadata', 'EntitiesDescriptor');
 $entitiesDescriptor->setAttribute('Name', $id);
@@ -107,6 +110,7 @@ foreach ($entities as $entity => $sets) {
 	$entitiesDescriptor->appendChild($xml->importNode($entityDescriptor, TRUE));
 }
 
+
 /* Sign the metadata if enabled. */
 if ($aggregatorConfig->getBoolean('sign.enable', FALSE)) {
 	$privateKey = $aggregatorConfig->getString('sign.privatekey');
@@ -122,12 +126,14 @@ if ($aggregatorConfig->getBoolean('sign.enable', FALSE)) {
 	$signer->sign($entitiesDescriptor, $entitiesDescriptor, $entitiesDescriptor->firstChild);
 }
 
+
 /* Show the metadata. */
 if(array_key_exists('mimetype', $_GET)) {
 	$mimeType = $_GET['mimetype'];
 } else {
 	$mimeType = 'application/samlmetadata+xml';
 }
+
 header('Content-Type: ' . $mimeType);
 
 echo($xml->saveXML());