Skip to content

Commit

Permalink
bring the realpath back
Browse files Browse the repository at this point in the history
  • Loading branch information
miladrahimi committed Jun 1, 2024
1 parent e8b96a7 commit 23d51fe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
5 changes: 2 additions & 3 deletions src/Cryptography/Keys/EcdsaPrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class EcdsaPrivateKey
{
/**
* @var mixed Key file resource handler
* @var resource Key resource handler
*/
protected $resource;

Expand All @@ -23,7 +22,7 @@ class EcdsaPrivateKey
*/
public function __construct(string $key, string $passphrase = '', ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand Down
5 changes: 2 additions & 3 deletions src/Cryptography/Keys/EcdsaPublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class EcdsaPublicKey
{
/**
* @var mixed Key file resource handler
* @var resource Key resource handler
*/
protected $resource;

Expand All @@ -22,7 +21,7 @@ class EcdsaPublicKey
*/
public function __construct(string $key, ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand Down
5 changes: 2 additions & 3 deletions src/Cryptography/Keys/RsaPrivateKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class RsaPrivateKey
{
/**
* @var mixed Key file resource handler
* @var resource Key resource handler
*/
protected $resource;

Expand All @@ -23,7 +22,7 @@ class RsaPrivateKey
*/
public function __construct(string $key, string $passphrase = '', ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_private($content, $passphrase);
if ($this->resource === false) {
Expand Down
5 changes: 2 additions & 3 deletions src/Cryptography/Keys/RsaPublicKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
namespace MiladRahimi\Jwt\Cryptography\Keys;

use MiladRahimi\Jwt\Exceptions\InvalidKeyException;
use Throwable;

class RsaPublicKey
{
/**
* @var mixed Key file resource handler
* @var resource Key resource handler
*/
protected $resource;

Expand All @@ -22,7 +21,7 @@ class RsaPublicKey
*/
public function __construct(string $key, ?string $id = null)
{
$content = file_exists($key) ? file_get_contents($key) : $key;
$content = file_exists($key) ? file_get_contents(realpath($key)) : $key;

$this->resource = openssl_pkey_get_public($content);
if ($this->resource === false) {
Expand Down

0 comments on commit 23d51fe

Please sign in to comment.