@@ -596,8 +596,10 @@ public function checkSPSettings(array $settings)
596596 }
597597
598598 if (isset ($ security ['signMetadata ' ]) && is_array ($ security ['signMetadata ' ])) {
599- if (!isset ($ security ['signMetadata ' ]['keyFileName ' ])
600- || !isset ($ security ['signMetadata ' ]['certFileName ' ])
599+ if ((!isset ($ security ['signMetadata ' ]['keyFileName ' ])
600+ || !isset ($ security ['signMetadata ' ]['certFileName ' ])) &&
601+ (!isset ($ security ['signMetadata ' ]['privateKey ' ])
602+ || !isset ($ security ['signMetadata ' ]['x509cert ' ]))
601603 ) {
602604 $ errors [] = 'sp_signMetadata_invalid ' ;
603605 }
@@ -800,7 +802,7 @@ public function shouldCompressResponses()
800802 *
801803 * @param bool $alwaysPublishEncryptionCert When 'true', the returned
802804 * metadata will always include an 'encryption' KeyDescriptor. Otherwise,
803- * the 'encryption' KeyDescriptor will only be included if
805+ * the 'encryption' KeyDescriptor will only be included if
804806 * $advancedSettings['security']['wantNameIdEncrypted'] or
805807 * $advancedSettings['security']['wantAssertionsEncrypted'] are enabled.
806808 * @param int|null $validUntil Metadata's valid time
@@ -851,15 +853,8 @@ public function getSPMetadata($alwaysPublishEncryptionCert = false, $validUntil
851853 Error::PUBLIC_CERT_FILE_NOT_FOUND
852854 );
853855 }
854- } else {
855- if (!isset ($ this ->_security ['signMetadata ' ]['keyFileName ' ])
856- || !isset ($ this ->_security ['signMetadata ' ]['certFileName ' ])
857- ) {
858- throw new Error (
859- 'Invalid Setting: signMetadata value of the sp is not valid ' ,
860- Error::SETTINGS_INVALID_SYNTAX
861- );
862- }
856+ } else if (isset ($ this ->_security ['signMetadata ' ]['keyFileName ' ]) &&
857+ isset ($ this ->_security ['signMetadata ' ]['certFileName ' ])) {
863858 $ keyFileName = $ this ->_security ['signMetadata ' ]['keyFileName ' ];
864859 $ certFileName = $ this ->_security ['signMetadata ' ]['certFileName ' ];
865860
@@ -883,6 +878,29 @@ public function getSPMetadata($alwaysPublishEncryptionCert = false, $validUntil
883878 }
884879 $ keyMetadata = file_get_contents ($ keyMetadataFile );
885880 $ certMetadata = file_get_contents ($ certMetadataFile );
881+ } else if (isset ($ this ->_security ['signMetadata ' ]['privateKey ' ]) &&
882+ isset ($ this ->_security ['signMetadata ' ]['x509cert ' ])) {
883+ $ keyMetadata = Utils::formatPrivateKey ($ this ->_security ['signMetadata ' ]['privateKey ' ]);
884+ $ certMetadata = Utils::formatCert ($ this ->_security ['signMetadata ' ]['x509cert ' ]);
885+ if (!$ keyMetadata ) {
886+ throw new Error (
887+ 'Private key not found. ' ,
888+ Error::PRIVATE_KEY_FILE_NOT_FOUND
889+ );
890+ }
891+
892+ if (!$ certMetadata ) {
893+ throw new Error (
894+ 'Public cert not found. ' ,
895+ Error::PUBLIC_CERT_FILE_NOT_FOUND
896+ );
897+ }
898+ } else {
899+ throw new Error (
900+ 'Invalid Setting: signMetadata value of the sp is not valid ' ,
901+ Error::SETTINGS_INVALID_SYNTAX
902+ );
903+
886904 }
887905
888906 $ signatureAlgorithm = $ this ->_security ['signatureAlgorithm ' ];
0 commit comments