Skip to content

Commit bc76770

Browse files
authored
Fix openssl error reporting (#512)
Fix openssl error reporting
1 parent 80361f4 commit bc76770

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Library/KeyManagement/KeyConverter/KeyConverter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
use function in_array;
1919
use function is_array;
2020
use function is_string;
21+
use const E_ERROR;
22+
use const E_PARSE;
2123
use const OPENSSL_KEYTYPE_EC;
2224
use const OPENSSL_KEYTYPE_RSA;
2325
use const OPENSSL_RAW_DATA;
@@ -48,6 +50,7 @@ public static function loadKeyFromCertificate(string $certificate): array
4850
throw new RuntimeException('Please install the OpenSSL extension');
4951
}
5052

53+
$errorReporting = error_reporting(E_ERROR | E_PARSE);
5154
try {
5255
$res = openssl_x509_read($certificate);
5356
if ($res === false) {
@@ -56,6 +59,8 @@ public static function loadKeyFromCertificate(string $certificate): array
5659
} catch (Throwable) {
5760
$certificate = self::convertDerToPem($certificate);
5861
$res = openssl_x509_read($certificate);
62+
} finally {
63+
error_reporting($errorReporting);
5964
}
6065
if ($res === false) {
6166
throw new InvalidArgumentException('Unable to load the certificate.');

0 commit comments

Comments
 (0)