From e2d8c60a30e1e45fc96e3c6b601a902179e958f3 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Mon, 20 Oct 2008 08:29:39 +0000
Subject: [PATCH] AuthnResponse: Use SimpleSAML_Utilities::loadPrivateKey

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@930 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/XML/SAML20/AuthnResponse.php | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/lib/SimpleSAML/XML/SAML20/AuthnResponse.php b/lib/SimpleSAML/XML/SAML20/AuthnResponse.php
index 49959855d..57b33a27d 100644
--- a/lib/SimpleSAML/XML/SAML20/AuthnResponse.php
+++ b/lib/SimpleSAML/XML/SAML20/AuthnResponse.php
@@ -192,17 +192,11 @@ class SimpleSAML_XML_SAML20_AuthnResponse extends SimpleSAML_XML_AuthnResponse {
 				if ($objKeyInfo = $objenc->locateKeyInfo($objKey)) {
 					if ($objKeyInfo->isEncrypted) {
 						$objencKey = $objKeyInfo->encryptedCtx;
-						if (!isset($spmd['privatekey'])) {
-							throw new Exception("Private key for decrypting assertion needed, but not specified for saml20-sp-hosted id: " . $spid);
+						$privatekey = SimpleSAML_Utilities::loadPrivateKey($spmd, TRUE);
+						if(array_key_exists('password', $privatekey)) {
+							$objKeyInfo->passphrase = $privatekey['password'];
 						}
-						$privatekey = @file_get_contents($this->configuration->getPathValue('certdir') . $spmd['privatekey']);
-						if ($privatekey === FALSE) {
-							throw new Exception("Private key for decrypting assertion specified but not found for saml20-sp-hosted id: " . $spid . " Filename: " . $spmd['privatekey']);
-						}
-						if(array_key_exists('privatekey_pass', $spmd)) {
-							$objKeyInfo->passphrase = $spmd['privatekey_pass'];
-						}
-						$objKeyInfo->loadKey($privatekey);
+						$objKeyInfo->loadKey($privatekey['PEM']);
 						$key = $objencKey->decryptKey($objKeyInfo);
 					} else {
 						$idpmd = $this->metadata->getMetaData($this->issuer, 'saml20-idp-remote');
-- 
GitLab