Skip to content

Commit

Permalink
Add passphrase option for signing certificate
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen authored May 15, 2019
1 parent 7f51918 commit 16f0c42
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/IdP/ADFS.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ private static function generateResponse($issuer, $target, $nameid, $attributes,
* @param string $algo
* @return string
*/
private static function signResponse($response, $key, $cert, $algo)
private static function signResponse($response, $key, $cert, $algo, $passphrase)
{
$objXMLSecDSig = new XMLSecurityDSig();
$objXMLSecDSig->idKeys = ['AssertionID'];
Expand All @@ -160,6 +160,9 @@ private static function signResponse($response, $key, $cert, $algo)
);

$objKey = new XMLSecurityKey($algo, ['type' => 'private']);
if (is_string($passphrase)) {
$objKey->passphrase = $passphrase;
}
$objKey->loadKey($key, true);
$objXMLSecDSig->sign($objKey);
if ($cert) {
Expand Down Expand Up @@ -364,12 +367,13 @@ public static function sendResponse(array $state)

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

$algo = $spMetadata->getString('signature.algorithm', null);
if ($algo === null) {
$algo = $idpMetadata->getString('signature.algorithm', XMLSecurityKey::RSA_SHA256);
}
$wresult = ADFS::signResponse($response, $privateKeyFile, $certificateFile, $algo);
$wresult = ADFS::signResponse($response, $privateKeyFile, $certificateFile, $algo, $passphrase);

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

0 comments on commit 16f0c42

Please sign in to comment.