We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ef11095 commit 1007102Copy full SHA for 1007102
1 file changed
src/Key/PrivateKey.php
@@ -54,8 +54,11 @@ public static function fromFile(
54
#[\SensitiveParameter]
55
string $passphrase = '',
56
): static {
57
- if (preg_match('/^(file:\/\/)/i', $file) !== 1) {
58
- $file = preg_filter('/^/', 'file://', $file);
+ if (preg_match(PEM::PEM_REGEX, $file) !== 1) {
+ // Not a PEM-encoded key. Must be a file
59
+ if (preg_match('/^(file:\/\/)/i', $file) !== 1) {
60
+ $file = preg_filter('/^/', 'file://', $file);
61
+ }
62
}
63
64
if (($key = openssl_pkey_get_private($file, $passphrase)) === false) {
0 commit comments