diff --git a/shard.yml b/shard.yml index 940c8aa..51a8063 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: jwt -version: 1.1.2 +version: 1.2.0 authors: - Potapov Sergey @@ -7,5 +7,6 @@ authors: dependencies: openssl_ext: github: stakach/openssl_ext + version: ~> 1.1 license: MIT diff --git a/spec/integration/algorithms/rsa_spec.cr b/spec/integration/algorithms/rsa_spec.cr index 84fc800..88fcebf 100644 --- a/spec/integration/algorithms/rsa_spec.cr +++ b/spec/integration/algorithms/rsa_spec.cr @@ -25,7 +25,7 @@ describe JWT do "FLscCAkdAP9lDgeDGwIDAQAB\n" + "-----END PUBLIC KEY-----\n" - wrong_key = OpenSSL::RSA.new(1024).to_pem + wrong_key = OpenSSL::PKey::RSA.new(1024).to_pem payload = {"foo" => "bar"} algorithms = { diff --git a/src/jwt.cr b/src/jwt.cr index ff4e49a..5b26f2c 100644 --- a/src/jwt.cr +++ b/src/jwt.cr @@ -38,7 +38,7 @@ module JWT # public key verification for RSA and ECDSA algorithms case algorithm when Algorithm::RS256, Algorithm::RS384, Algorithm::RS512 - rsa = OpenSSL::RSA.new(key) + rsa = OpenSSL::PKey::RSA.new(key) digest = OpenSSL::Digest.new("sha#{algorithm.to_s[2..-1]}") if !rsa.verify(digest, Base64.decode_string(encoded_signature), verify_data) raise VerificationError.new("Signature verification failed") @@ -99,11 +99,11 @@ module JWT when Algorithm::HS512 OpenSSL::HMAC.digest(:sha512, key, data) when Algorithm::RS256 - OpenSSL::RSA.new(key).sign(OpenSSL::Digest.new("sha256"), data) + OpenSSL::PKey::RSA.new(key).sign(OpenSSL::Digest.new("sha256"), data) when Algorithm::RS384 - OpenSSL::RSA.new(key).sign(OpenSSL::Digest.new("sha384"), data) + OpenSSL::PKey::RSA.new(key).sign(OpenSSL::Digest.new("sha384"), data) when Algorithm::RS512 - OpenSSL::RSA.new(key).sign(OpenSSL::Digest.new("sha512"), data) + OpenSSL::PKey::RSA.new(key).sign(OpenSSL::Digest.new("sha512"), data) else raise(UnsupportedAlgorithmError.new("Unsupported algorithm: #{algorithm}")) end end