diff --git a/modules/admin/lib/FederationController.php b/modules/admin/lib/FederationController.php
index 5680c2cc8a7a4c20c3ffb657518a71c0462c56b3..0f7ac4ca9f2f94238166f9592d4b4ef4aa4063e3 100644
--- a/modules/admin/lib/FederationController.php
+++ b/modules/admin/lib/FederationController.php
@@ -330,8 +330,8 @@ 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($metadata['keys']) === 1) {
+            $certificates = $metadata['keys'] ?? [];
+            if (count($certificates) === 1) {
                 $cert = array_pop($metadata['keys']);
                 $metadata['certData'] = $cert['X509Certificate'];
                 unset($metadata['keys']);