diff --git a/.github/workflows/phpunit.yml b/.github/workflows/phpunit.yml index e0344e2..91bc61c 100644 --- a/.github/workflows/phpunit.yml +++ b/.github/workflows/phpunit.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: true matrix: - php: [8.2, 8.3, 8.4] + php: [8.2, 8.3, 8.4, 8.5] laravel: [11.*, 12.*] stability: [prefer-stable] include: diff --git a/config/php-saml-toolkit.php b/config/php-saml-toolkit.php index fb66c47..a645410 100644 --- a/config/php-saml-toolkit.php +++ b/config/php-saml-toolkit.php @@ -267,14 +267,9 @@ | certificates here. | */ - // 'x509certMulti' => [ - // 'signing' => [ - // 0 => '', - // ], - // 'encryption' => [ - // 0 => '', - // ], - // ], + 'x509certMulti' => (file_exists($cert_path.'/idp_cert_multi.json')) + ? json_decode(file_get_contents($cert_path.'/idp_cert_multi.json'), true) + : null, ], ]; diff --git a/src/Commands/GenerateKeys.php b/src/Commands/GenerateKeys.php index e565c1e..1f63d57 100644 --- a/src/Commands/GenerateKeys.php +++ b/src/Commands/GenerateKeys.php @@ -21,10 +21,19 @@ public function handle(): void File::ensureDirectoryExists($certPath); $idpCertPath = $certPath.'/idp_cert.pem'; - if ($force || ! File::exists($idpCertPath)) { + $idpMultiCertPath = $certPath.'/idp_cert_multi.json'; + if ($force || (! File::exists($idpCertPath) && ! File::exists($idpMultiCertPath))) { + // Remove any existing cert files + File::exists($idpCertPath) && File::delete($idpCertPath); + File::exists($idpMultiCertPath) && File::delete($idpMultiCertPath); + $this->info('Downloading IDP certificate...'); $idpCertContents = $this->getIdpCert($weill); - File::put($idpCertPath, $idpCertContents); + if (! empty($idpCertContents['x509certMulti'])) { + File::put($idpMultiCertPath, json_encode($idpCertContents['x509certMulti'], JSON_PRETTY_PRINT)); + } else { + File::put($idpCertPath, $idpCertContents['x509cert']); + } } else { $this->info('IDP certificate already exists.'); } @@ -57,7 +66,7 @@ public function handle(): void $this->info('Keys generated successfully.'); } - private function getIdpCert(bool $weill): string|false + private function getIdpCert(bool $weill): array|false { if ($weill) { $metadataUrl = app()->isProduction() @@ -72,7 +81,7 @@ private function getIdpCert(bool $weill): string|false } return app()->runningUnitTests() - ? $testContent // Placeholder content for testing - : IdPMetadataParser::parseRemoteXML($metadataUrl)['idp']['x509cert']; + ? ['x509cert' => $testContent] // Placeholder content for testing + : IdPMetadataParser::parseRemoteXML($metadataUrl)['idp']; } }