diff --git a/config-templates/config.php b/config-templates/config.php
index 386d58f6103208056bc6915f1baa4b0a88add1dd..3d1609c8b032287a847c495e3a8d143f7288a7f2 100644
--- a/config-templates/config.php
+++ b/config-templates/config.php
@@ -181,7 +181,7 @@ $config = array (
 	 * By default simpleSAMLphp will use its builtin IdP discovery service.
 	 */
 	'idpdisco.url.shib13' => NULL,
-	'idpdisco.url.saml2' => NULL,
+	'idpdisco.url.saml20' => NULL,
 	
 	/*
 	 * IdP Discovery service look configuration. 
diff --git a/docs/source/simplesamlphp-sp.xml b/docs/source/simplesamlphp-sp.xml
index bfb6d04cab303940c86a0c93e90651937f93582b..8f8178b9af395a9803e239d86afc13a141f96119 100644
--- a/docs/source/simplesamlphp-sp.xml
+++ b/docs/source/simplesamlphp-sp.xml
@@ -293,7 +293,7 @@
             <glossdef>
               <para>Set which IdP discovery service this SP should use. If
               this is unset, the IdP discovery service specified in the global
-              option <literal>idpdisco.url.saml2</literal> in
+              option <literal>idpdisco.url.saml20</literal> in
               <filename>config/config.php</filename> will be used. If that one
               is also unset, the builtin default discovery service will be
               used.</para>
diff --git a/www/saml2/sp/initSSO.php b/www/saml2/sp/initSSO.php
index 1e0a77f5af5a455327ca531ad129be4d71d200b6..61c3d9f19f1ac390b777e1efa8513dcabde98f32 100644
--- a/www/saml2/sp/initSSO.php
+++ b/www/saml2/sp/initSSO.php
@@ -31,7 +31,7 @@ try {
 
 	if($idpentityid === NULL) {
 		/* We are going to need the SP metadata to determine which IdP discovery service we should use. */
-		$spmetadata = $metadata->getMetaData($spentityid);
+		$spmetadata = $metadata->getMetaDataCurrent('saml20-sp-hosted');
 	}
 
 } catch (Exception $exception) {
@@ -51,8 +51,8 @@ if ($idpentityid == null) {
 	 */
 	if(array_key_exists('idpdisco.url', $spmetadata)) {
 		$discourl = $spmetadata['idpdisco.url'];
-	} elseif($config->getValue('idpdisco.url.saml2', NULL) !== NULL) {
-		$discourl = $config->getValue('idpdisco.url.saml2', NULL);
+	} elseif($config->getValue('idpdisco.url.saml20', NULL) !== NULL) {
+		$discourl = $config->getValue('idpdisco.url.saml20', NULL);
 	} else {
 		$discourl = '/' . $config->getBaseURL() . 'saml2/sp/idpdisco.php';
 	}