Skip to content
Snippets Groups Projects
Commit e4c09afb authored by Olav Morken's avatar Olav Morken
Browse files

saml/idp/SAML2: Encrypt assertion using encryption key.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2510 44740490-163a-0410-bde0-09ae8108e29a
parent 354edab2
No related branches found
No related tags found
No related merge requests found
...@@ -671,18 +671,21 @@ class sspmod_saml_IdP_SAML2 { ...@@ -671,18 +671,21 @@ class sspmod_saml_IdP_SAML2 {
$key = new XMLSecurityKey(XMLSecurityKey::AES128_CBC); $key = new XMLSecurityKey(XMLSecurityKey::AES128_CBC);
$key->loadKey($sharedKey); $key->loadKey($sharedKey);
} else { } else {
/* Find the certificate that we should use to encrypt messages to this SP. */ $keys = $spMetadata->getPublicKeys('encryption', TRUE);
$certArray = SimpleSAML_Utilities::loadPublicKey($spMetadata, TRUE); $key = $keys[0];
if (!array_key_exists('PEM', $certArray)) { switch ($key['type']) {
throw new Exception('Unable to locate key we should use to encrypt the assertionst ' . case 'X509Certificate':
'to the SP: ' . var_export($spMetadata->getString('entityid'), TRUE) . '.'); $pemKey = "-----BEGIN CERTIFICATE-----\n" .
chunk_split($key['X509Certificate'], 64) .
"-----END CERTIFICATE-----\n";
break;
default:
throw new SimpleSAML_Error_Exception('Unsupported encryption key type: ' . $key['type']);
} }
$pemCert = $certArray['PEM'];
/* Extract the public key from the certificate for encryption. */ /* Extract the public key from the certificate for encryption. */
$key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'public')); $key = new XMLSecurityKey(XMLSecurityKey::RSA_1_5, array('type'=>'public'));
$key->loadKey($pemCert); $key->loadKey($pemKey);
} }
$ea = new SAML2_EncryptedAssertion(); $ea = new SAML2_EncryptedAssertion();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment