diff --git a/docs/simplesamlphp-reference-sp-remote.txt b/docs/simplesamlphp-reference-sp-remote.txt index bb012079d436120fb28e0e0d6fa9ad87e6ff0d1a..6d9d82d0cfaf522e8606d0ab4fa21753a9ea064e 100644 --- a/docs/simplesamlphp-reference-sp-remote.txt +++ b/docs/simplesamlphp-reference-sp-remote.txt @@ -249,6 +249,14 @@ The following SAML 2.0 options are available: * `http://www.w3.org/2001/04/xmldsig-more#rsa-sha384` * `http://www.w3.org/2001/04/xmldsig-more#rsa-sha512` +`signature.privatekey` +: Name of private key file for this IdP, in PEM format. The filename is relative to the cert/-directory. +: Note that this option also exists in the IdP-hosted metadata. This entry in the SP-remote metadata overrides the option `privatekey` in the IdP-hosted metadata. + +`signature.privatekey_pass` +: Passphrase for the private key. Leave this option out if the private key is unencrypted. +: Note that this option only is used if `signature.privatekey` is present. + `simplesaml.nameidattribute` : When the value of the `NameIDFormat`-option is set to either `email` or `persistent`, this is the name of the attribute which diff --git a/modules/saml/lib/Message.php b/modules/saml/lib/Message.php index 62731a7b046af6656b42e7da54c2c09e445e2b29..0a1a7eae2db320b944d7f2e590baed4613902120 100644 --- a/modules/saml/lib/Message.php +++ b/modules/saml/lib/Message.php @@ -18,8 +18,16 @@ class sspmod_saml_Message { */ public static function addSign(SimpleSAML_Configuration $srcMetadata, SimpleSAML_Configuration $dstMetadata, SAML2_SignedElement $element) { - $keyArray = SimpleSAML_Utilities::loadPrivateKey($srcMetadata, TRUE); - $certArray = SimpleSAML_Utilities::loadPublicKey($srcMetadata, FALSE); + $dstPrivateKey = $dstMetadata->getString('signature.privatekey', NULL); + + if($dstPrivateKey !== NULL) { + $keyArray = SimpleSAML_Utilities::loadPrivateKey($dstMetadata, TRUE, 'signature.'); + $certArray = SimpleSAML_Utilities::loadPublicKey($dstMetadata, FALSE, 'signature.'); + } + else { + $keyArray = SimpleSAML_Utilities::loadPrivateKey($srcMetadata, TRUE); + $certArray = SimpleSAML_Utilities::loadPublicKey($srcMetadata, FALSE); + } $algo = $dstMetadata->getString('signature.algorithm', NULL); if ($algo === NULL) {