diff --git a/src/Library/KeyManagement/KeyConverter/KeyConverter.php b/src/Library/KeyManagement/KeyConverter/KeyConverter.php index 9acd843c..d9c3bd72 100644 --- a/src/Library/KeyManagement/KeyConverter/KeyConverter.php +++ b/src/Library/KeyManagement/KeyConverter/KeyConverter.php @@ -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; @@ -48,6 +50,7 @@ public static function loadKeyFromCertificate(string $certificate): array throw new RuntimeException('Please install the OpenSSL extension'); } + $errorReporting = error_reporting(E_ERROR | E_PARSE); try { $res = openssl_x509_read($certificate); if ($res === false) { @@ -56,6 +59,8 @@ public static function loadKeyFromCertificate(string $certificate): array } catch (Throwable) { $certificate = self::convertDerToPem($certificate); $res = openssl_x509_read($certificate); + } finally { + error_reporting($errorReporting); } if ($res === false) { throw new InvalidArgumentException('Unable to load the certificate.');