Skip to content

Commit cbfdd50

Browse files
monkeyiqtvdijen
andcommitted
Warn the user if they do not also set sign.enabled in metadata file (simplesamlphp#2466)
* Warn the user if they do not also set sign.enabled in metadata file This block needs to be enabled in the metadata file to have the effect. * lint * Update lock-file --------- Co-authored-by: Tim van Dijen <tvdijen@gmail.com>
1 parent 2b950c2 commit cbfdd50

2 files changed

Lines changed: 24 additions & 2 deletions

File tree

docs/simplesamlphp-advancedfeatures.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ The default is not to use a proxy ('proxy' = null) and no username and password
5757

5858
## Metadata signing
5959

60-
SimpleSAMLphp supports signing of the metadata it generates. Metadata signing is configured by four options:
60+
SimpleSAMLphp supports signing of the metadata it generates.
61+
62+
Metadata signing is configured by four options:
6163

6264
- `metadata.sign.enable`: Whether metadata signing should be enabled or not. Set to `TRUE` to enable metadata signing. Defaults to `FALSE`.
6365
- `metadata.sign.privatekey`: Location of the private key data which should be used to sign the metadata.
@@ -71,7 +73,13 @@ SimpleSAMLphp supports signing of the metadata it generates. Metadata signing is
7173
- `http://www.w3.org/2001/04/xmldsig-more#rsa-sha384`
7274
- `http://www.w3.org/2001/04/xmldsig-more#rsa-sha512`
7375

74-
These options can be configured globally in the `config/config.php`-file, or per SP/IdP by adding them to the hosted metadata for the SP/IdP. The configuration in the metadata for the SP/IdP takes precedence over the global configuration.
76+
These options can be configured globally in the
77+
`config/config.php`-file, or per SP/IdP by adding them to the hosted
78+
metadata for the SP/IdP. The configuration in the metadata for the
79+
SP/IdP takes precedence over the global configuration. Note that if
80+
wish to set the metadata.sign.privatekey and metadata.sign.certificate
81+
in a metadata file you need to also set metadata.sign.enable=true in
82+
that metadata file.
7583

7684
There is also an additional fallback for the private key and the certificate. If `metadata.sign.privatekey` and `metadata.sign.certificate` isn't configured, SimpleSAMLphp will use the `privatekey`, `privatekey_pass` and `certificate` options in the metadata for the SP/IdP.
7785

src/SimpleSAML/Metadata/MetaDataStorageHandler.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,20 @@ public function getMetaData(?string $entityId, string $set): array
342342
}
343343
}
344344

345+
if (!array_key_exists('metadata.sign.enable', $metadata)) {
346+
// The admin needs to set the .enable setting to make these
347+
// specific keys be used.
348+
if (
349+
array_key_exists('metadata.sign.privatekey', $metadata)
350+
|| array_key_exists('metadata.sign.certificate', $metadata)
351+
) {
352+
Logger::error("SIGNING: Please set metadata.sign.enable=true when"
353+
. " you wish to specify the privatekey and certificate"
354+
. " in the metadata file."
355+
. " See entity $entityId");
356+
}
357+
}
358+
345359
$metadata['metadata-index'] = $entityId;
346360
$metadata['metadata-set'] = $set;
347361
Assert::keyExists($metadata, 'entityid');

0 commit comments

Comments
 (0)