diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php
index e6fc47a5444f5da9116b32e0b9f516d209fb6c30..222c3e3a8cfbb577a5d12e29f9a87ac6ec2457b6 100644
--- a/modules/saml/www/sp/saml2-acs.php
+++ b/modules/saml/www/sp/saml2-acs.php
@@ -18,9 +18,25 @@ if (!($response instanceof SAML2_Response)) {
 	throw new SimpleSAML_Error_BadRequest('Invalid message received to AssertionConsumerService endpoint.');
 }
 
+$idp = $response->getIssuer();
+if ($idp === NULL) {
+	/* No Issuer in the response. Look for an unencrypted assertion with an issuer. */
+	foreach ($response->getAssertions() as $a) {
+		if ($a instanceof SAML2_Assertion) {
+			/* We found an unencrypted assertion - there should be an issuer here. */
+			$idp = $a->getIssuer();
+			break;
+		}
+	}
+	if ($idp === NULL) {
+		/* No issuer found in the assertions. */
+		throw new Exception('Missing <saml:Issuer> in message delivered to AssertionConsumerService.');
+	}
+}
+
 $session = SimpleSAML_Session::getInstance();
 $prevAuth = $session->getAuthData($sourceId, 'saml:sp:prevAuth');
-if ($prevAuth !== NULL && $prevAuth['id'] === $response->getId() && $prevAuth['issuer'] === $response->getIssuer()) {
+if ($prevAuth !== NULL && $prevAuth['id'] === $response->getId() && $prevAuth['issuer'] === $idp) {
 	/* OK, it looks like this message has the same issuer
 	 * and ID as the SP session we already have active. We
 	 * therefore assume that the user has somehow triggered
@@ -51,11 +67,6 @@ if (!empty($stateId)) {
 	);
 }
 
-$idp = $response->getIssuer();
-if ($idp === NULL) {
-	throw new Exception('Missing <saml:Issuer> in message delivered to AssertionConsumerService.');
-}
-
 SimpleSAML_Logger::debug('Received SAML2 Response from ' . var_export($idp, TRUE) . '.');
 
 $idpMetadata = $source->getIdPmetadata($idp);