diff --git a/modules/saml/www/sp/metadata.php b/modules/saml/www/sp/metadata.php
index f1a7d88a025a6a3b0f7c75cbeeaf4b25e144518d..becac2d2db2bed9774927fd6d931196c8187d95e 100644
--- a/modules/saml/www/sp/metadata.php
+++ b/modules/saml/www/sp/metadata.php
@@ -207,6 +207,9 @@ unset($metaArray20['UIInfo']);
 unset($metaArray20['metadata-set']);
 unset($metaArray20['entityid']);
 
+// sanitize the attributes array to remove friendly names
+$metaArray20['attributes'] = array_values($metaArray20['attributes']);
+
 /* Sign the metadata if enabled. */
 $xml = SimpleSAML_Metadata_Signer::sign($xml, $spconfig->toArray(), 'SAML 2 SP');