Skip to content

Commit 16f0c42

Browse files
authored
Add passphrase option for signing certificate
1 parent 7f51918 commit 16f0c42

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/IdP/ADFS.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ private static function generateResponse($issuer, $target, $nameid, $attributes,
140140
* @param string $algo
141141
* @return string
142142
*/
143-
private static function signResponse($response, $key, $cert, $algo)
143+
private static function signResponse($response, $key, $cert, $algo, $passphrase)
144144
{
145145
$objXMLSecDSig = new XMLSecurityDSig();
146146
$objXMLSecDSig->idKeys = ['AssertionID'];
@@ -160,6 +160,9 @@ private static function signResponse($response, $key, $cert, $algo)
160160
);
161161

162162
$objKey = new XMLSecurityKey($algo, ['type' => 'private']);
163+
if (is_string($passphrase)) {
164+
$objKey->passphrase = $passphrase;
165+
}
163166
$objKey->loadKey($key, true);
164167
$objXMLSecDSig->sign($objKey);
165168
if ($cert) {
@@ -364,12 +367,13 @@ public static function sendResponse(array $state)
364367

365368
$privateKeyFile = \SimpleSAML\Utils\Config::getCertPath($idpMetadata->getString('privatekey'));
366369
$certificateFile = \SimpleSAML\Utils\Config::getCertPath($idpMetadata->getString('certificate'));
370+
$passphrase = $idpMetadata->getString('privatekey_pass', null);
367371

368372
$algo = $spMetadata->getString('signature.algorithm', null);
369373
if ($algo === null) {
370374
$algo = $idpMetadata->getString('signature.algorithm', XMLSecurityKey::RSA_SHA256);
371375
}
372-
$wresult = ADFS::signResponse($response, $privateKeyFile, $certificateFile, $algo);
376+
$wresult = ADFS::signResponse($response, $privateKeyFile, $certificateFile, $algo, $passphrase);
373377

374378
$wctx = $state['adfs:wctx'];
375379
$wreply = $state['adfs:wreply'] ? : $spMetadata->getValue('prp');

0 commit comments

Comments
 (0)