Skip to content

Commit f99217b

Browse files
authored
Add the possibility to continue if no encryption cert is available (#2208)
* Add the possibility to continue unencrypted if no encryption cert is available * Fix review comments
1 parent d5e4ad4 commit f99217b

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

docs/simplesamlphp-reference-idp-hosted.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,13 @@ The following SAML 2.0 options are available:
142142

143143
`assertion.encryption`
144144
: Whether assertions sent from this IdP should be encrypted. The default
145-
value is `FALSE`.
145+
value is `FALSE`. When set to `TRUE` encryption will be enforced for all
146+
remote SP's and an exception is thrown if encryption fails.
146147

147148
: Note that this option can be set for each SP in the SP-remote metadata.
148149

150+
: Note that enforcement can be disabled by setting `encryption.optional` to `TRUE`.
151+
149152
`attributeencodings`
150153
: What encoding should be used for the different attributes. This is
151154
an array which maps attribute names to attribute encodings. There
@@ -190,6 +193,10 @@ The following SAML 2.0 options are available:
190193
any value in the SP-remote metadata overrides the one configured
191194
in the IdP metadata.
192195

196+
`encryption.optional`
197+
: Whether or not we may continue to send an unencrypted assertion if the SP has no encryption certificate.
198+
The default value is `FALSE`.
199+
193200
`encryption.blacklisted-algorithms`
194201
: Blacklisted encryption algorithms. This is an array containing the algorithm identifiers.
195202

modules/saml/src/IdP/SAML2.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1414,7 +1414,7 @@ private static function encryptAssertion(
14141414
Configuration $idpMetadata,
14151415
Configuration $spMetadata,
14161416
Assertion $assertion,
1417-
) {
1417+
): Assertion|EncryptedAssertion {
14181418
$encryptAssertion = $spMetadata->getOptionalBoolean('assertion.encryption', null);
14191419
if ($encryptAssertion === null) {
14201420
$encryptAssertion = $idpMetadata->getOptionalBoolean('assertion.encryption', false);
@@ -1452,6 +1452,8 @@ private static function encryptAssertion(
14521452
// extract the public key from the certificate for encryption
14531453
$key = new XMLSecurityKey(XMLSecurityKey::RSA_OAEP_MGF1P, ['type' => 'public']);
14541454
$key->loadKey($pemKey);
1455+
} elseif ($idpMetadata->getOptionalBoolean('encryption.optional', false) === true) {
1456+
return $assertion;
14551457
} else {
14561458
throw new Error\ConfigurationError(
14571459
'Missing encryption key for entity `' . $spMetadata->getString('entityid') . '`',

0 commit comments

Comments
 (0)