Skip to content

Commit bd495eb

Browse files
committed
Support combination of openssl GEM 3.0.1 with OpenSSL 3.0 on CI run
1 parent 1ef5247 commit bd495eb

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

lib/jwt/version.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,8 @@ def self.openssl_3?
2525
return false if OpenSSL::OPENSSL_VERSION.include?('LibreSSL')
2626
return true if OpenSSL::OPENSSL_VERSION_NUMBER >= 3 * 0x10000000
2727
end
28+
29+
def self.openssl_3_hmac_empty_key_regression?
30+
openssl_3? && ::Gem::Version.new(OpenSSL::VERSION) <= ::Gem::Version.new('3.0.0')
31+
end
2832
end

spec/integration/readme_examples_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
end
3030

3131
it 'decodes with HMAC algorithm without secret key' do
32-
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3?
32+
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3_hmac_empty_key_regression?
3333
token = JWT.encode payload, nil, 'HS256'
3434
decoded_token = JWT.decode token, nil, false
3535

spec/jwt_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@
629629

630630
context 'when hmac algorithm is used without secret key' do
631631
it 'encodes payload' do
632-
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3?
632+
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3_hmac_empty_key_regression?
633633
payload = { a: 1, b: 'b' }
634634

635635
token = JWT.encode(payload, '', 'HS256')
@@ -760,7 +760,7 @@
760760
describe 'when token signed with nil and decoded with nil' do
761761
let(:no_key_token) { ::JWT.encode(payload, nil, 'HS512') }
762762
it 'raises JWT::DecodeError' do
763-
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3?
763+
pending 'Different behaviour on OpenSSL 3.0 (https://github.com/openssl/openssl/issues/13089)' if ::JWT.openssl_3_hmac_empty_key_regression?
764764
expect { ::JWT.decode(no_key_token, nil, true, algorithms: 'HS512') }.to raise_error(JWT::DecodeError, 'No verification key available')
765765
end
766766
end

spec/spec_helper.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111

1212
require 'jwt'
1313

14+
puts "OpenSSL::VERSION: #{OpenSSL::VERSION}"
15+
puts "OpenSSL::OPENSSL_VERSION: #{OpenSSL::OPENSSL_VERSION}"
16+
puts "OpenSSL::OPENSSL_LIBRARY_VERSION: #{OpenSSL::OPENSSL_LIBRARY_VERSION}\n\n"
17+
1418
CERT_PATH = File.join(File.dirname(__FILE__), 'fixtures', 'certs')
1519

1620
RSpec.configure do |config|

0 commit comments

Comments
 (0)