From 5237fe45c5f8c1755dc6617465103dcc4e6a9ff5 Mon Sep 17 00:00:00 2001 From: Spomky Date: Thu, 4 Jan 2018 09:42:10 +0100 Subject: [PATCH] X5U Certification Loading This commit fixes a bug when the X5U certificates already have the BEGIN and END statements. --- src/Component/KeyManagement/X5UFactory.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Component/KeyManagement/X5UFactory.php b/src/Component/KeyManagement/X5UFactory.php index 89a61071..1aa49482 100644 --- a/src/Component/KeyManagement/X5UFactory.php +++ b/src/Component/KeyManagement/X5UFactory.php @@ -58,7 +58,9 @@ public function loadFromUrl(string $url, array $header = []): JWKSet $keys = []; foreach ($data as $kid => $cert) { - $cert = '-----BEGIN CERTIFICATE-----'.PHP_EOL.$cert.PHP_EOL.'-----END CERTIFICATE-----'; + if (false === strpos($cert, '-----BEGIN CERTIFICATE-----')) { + $cert = '-----BEGIN CERTIFICATE-----'.PHP_EOL.$cert.PHP_EOL.'-----END CERTIFICATE-----'; + } $jwk = KeyConverter::loadKeyFromCertificate($cert); if (is_string($kid)) { $jwk['kid'] = $kid;