Skip to content

Commit f654155

Browse files
committed
feat(rsakey): support both with/without file:// protocol
1 parent 5c648ae commit f654155

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

Diff for: src/ValidatesJWT.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,12 @@ protected function validateTimestamps(array $payload)
9595
*/
9696
protected function validateKey()
9797
{
98-
if (\is_string($this->key)) {
99-
if (!\is_file($this->key)) {
100-
throw new JWTException('Invalid key: Should be file path of private key', static::ERROR_KEY_INVALID);
98+
if (\is_string($key = $this->key)) {
99+
if (\substr($key, 0, 7) !== 'file://') {
100+
$key = 'file://' . $key;
101101
}
102102

103-
$this->key = \openssl_get_privatekey('file://' . $this->key, $this->passphrase ?? '');
103+
$this->key = \openssl_get_privatekey($key, $this->passphrase ?? '');
104104
}
105105

106106
if (!\is_resource($this->key)) {

0 commit comments

Comments
 (0)