diff --git a/modules/admin/lib/FederationController.php b/modules/admin/lib/FederationController.php
index 0f7ac4ca9f2f94238166f9592d4b4ef4aa4063e3..b0bcc47a4a9b1d824d9113b22fe58d43e786e7d9 100644
--- a/modules/admin/lib/FederationController.php
+++ b/modules/admin/lib/FederationController.php
@@ -330,11 +330,15 @@ class FederationController
         /** @var \SimpleSAML\Module\saml\Auth\Source\SP $source */
         foreach (\SimpleSAML\Auth\Source::getSourcesOfType('saml:SP') as $source) {
             $metadata = $source->getHostedMetadata();
-            $certificates = $metadata['keys'] ?? [];
-            if (count($certificates) === 1) {
-                $cert = array_pop($metadata['keys']);
-                $metadata['certData'] = $cert['X509Certificate'];
-                unset($metadata['keys']);
+            if (isset($metadata['keys']) ) {
+                $certificates = $metadata['keys'];
+                if (count($metadata['keys']) === 1) {
+                    $cert = array_pop($metadata['keys']);
+                    $metadata['certData'] = $cert['X509Certificate'];
+                    unset($metadata['keys']);
+                }
+            } else {
+                $certificates = [];
             }
 
             // get the name