Skip to content

Commit

Permalink
Fix openssl error reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Feb 1, 2024
1 parent 80361f4 commit 3b01852
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Library/KeyManagement/KeyConverter/KeyConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
use function in_array;
use function is_array;
use function is_string;
use const E_ERROR;
use const E_PARSE;
use const OPENSSL_KEYTYPE_EC;
use const OPENSSL_KEYTYPE_RSA;
use const OPENSSL_RAW_DATA;
Expand Down Expand Up @@ -49,13 +51,16 @@ public static function loadKeyFromCertificate(string $certificate): array
}

try {
$errorReporting = error_reporting(E_ERROR | E_PARSE);
$res = openssl_x509_read($certificate);
if ($res === false) {
throw new InvalidArgumentException('Unable to load the certificate.');
}
} catch (Throwable) {
$certificate = self::convertDerToPem($certificate);
$res = openssl_x509_read($certificate);
} finally {
error_reporting($errorReporting);

Check failure on line 63 in src/Library/KeyManagement/KeyConverter/KeyConverter.php

View workflow job for this annotation

GitHub Actions / 3️⃣ Static Analysis

Variable $errorReporting might not be defined.
}
if ($res === false) {
throw new InvalidArgumentException('Unable to load the certificate.');
Expand Down

0 comments on commit 3b01852

Please sign in to comment.