Skip to content

Commit 55c351e

Browse files
committed
Comment added regarding the potential security issue if the certificate chain is not verified.
Useless and inconsistent check removed.
1 parent ac395d4 commit 55c351e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/Component/KeyManagement/JWKFactory.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -359,6 +359,10 @@ public static function createFromKey(string $key, ?string $password = null, arra
359359

360360
/**
361361
* This method will try to load and convert a X.509 certificate chain into a public key.
362+
*
363+
* Be careful! The certificate chain is loaded, but it is NOT VERIFIED by any mean!
364+
* It is mandatory to verify the root CA or intermediate CA are trusted.
365+
* If not done, it may lead to potential security issues.
362366
*/
363367
public static function createFromX5C(array $x5c, array $additional_values = []): JWK
364368
{

src/Component/KeyManagement/KeyConverter/KeyConverter.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,11 @@ private static function sanitizePEM(string &$pem)
165165
$pem .= $matches[0][1].PHP_EOL;
166166
}
167167

168+
/**
169+
* Be careful! The certificate chain is loaded, but it is NOT VERIFIED by any mean!
170+
* It is mandatory to verify the root CA or intermediate CA are trusted.
171+
* If not done, it may lead to potential security issues.
172+
*/
168173
public static function loadFromX5C(array $x5c): array
169174
{
170175
$certificate = null;
@@ -204,9 +209,6 @@ public static function loadFromX5C(array $x5c): array
204209
}
205210
}
206211
}
207-
if (null === $certificate || null !== $last_issuer && \json_encode($last_issuer) !== \json_encode($last_subject)) {
208-
throw new \InvalidArgumentException('Invalid certificate chain.');
209-
}
210212

211213
return self::loadKeyFromCertificate($certificate);
212214
}

0 commit comments

Comments
 (0)