From af06650f30cdf9d3bba0fe37e7b32095dd471a18 Mon Sep 17 00:00:00 2001 From: Joris van Willigen Date: Thu, 10 Dec 2020 18:25:27 +0100 Subject: [PATCH] Update ValidatesJWT.php Please support PHP 8.0 https://php.watch/versions/8.0/OpenSSL-resource#openssl-resource-is_resource --- src/ValidatesJWT.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ValidatesJWT.php b/src/ValidatesJWT.php index 742c2c6..37e863e 100644 --- a/src/ValidatesJWT.php +++ b/src/ValidatesJWT.php @@ -114,7 +114,11 @@ protected function validateKey() $this->key = \openssl_get_privatekey($key, $this->passphrase ?: ''); } - if (!\is_resource($this->key)) { + if (\PHP_VERSION_ID < 80000 && !\is_resource($this->key)) { + throw new JWTException('Invalid key: Should be resource of private key', static::ERROR_KEY_INVALID); + } + + if (\PHP_VERSION_ID > 80000 && !($this->key instanceof OpenSSLAsymmetricKey || $this->key instanceof OpenSSLCertificate || $this->key instanceof OpenSSLCertificateSigningRequest)) { throw new JWTException('Invalid key: Should be resource of private key', static::ERROR_KEY_INVALID); } }