diff --git a/lib/jwt/version.rb b/lib/jwt/version.rb index 7ad81897..12e1773a 100644 --- a/lib/jwt/version.rb +++ b/lib/jwt/version.rb @@ -27,6 +27,10 @@ def self.openssl_3? end def self.openssl_3_hmac_empty_key_regression? - openssl_3? && ::Gem::Version.new(OpenSSL::VERSION) <= ::Gem::Version.new('3.0.0') + openssl_3? && openssl_version <= ::Gem::Version.new('3.0.0') + end + + def self.openssl_version + @openssl_version ||= ::Gem::Version.new(OpenSSL::VERSION) end end diff --git a/spec/jwk/rsa_spec.rb b/spec/jwk/rsa_spec.rb index 3de9995c..27572bd0 100644 --- a/spec/jwk/rsa_spec.rb +++ b/spec/jwk/rsa_spec.rb @@ -171,6 +171,10 @@ context 'when e, n, d is given' do let(:jwk_parameters) { all_jwk_parameters.slice(:e, :n, :d) } + before do + skip 'OpenSSL prior to 2.2 does not seem to support partial parameters' if ::JWT.openssl_version < ::Gem::Version.new('2.2') + end + it 'creates a valid RSA object representing a private key' do expect(subject).to be_a(::OpenSSL::PKey::RSA) expect(subject.private?).to eq(true) @@ -196,8 +200,8 @@ describe '.create_rsa_key_using_sets' do before do - skip unless OpenSSL::PKey::RSA.new.respond_to?(:set_key) - skip if ::JWT.openssl_3? + skip 'OpenSSL without the RSA#set_key method not supported' unless OpenSSL::PKey::RSA.new.respond_to?(:set_key) + skip 'OpenSSL 3.0 does not allow mutating objects anymore' if ::JWT.openssl_3? end subject(:rsa) { described_class.create_rsa_key_using_sets(rsa_parameters) } @@ -208,7 +212,7 @@ describe '.create_rsa_key_using_accessors' do before do - skip if OpenSSL::PKey::RSA.new.respond_to?(:set_key) + skip 'OpenSSL if RSA#set_key is available there is no accessors anymore' if OpenSSL::PKey::RSA.new.respond_to?(:set_key) end subject(:rsa) { described_class.create_rsa_key_using_accessors(rsa_parameters) }