jruby / jruby-openssl

JRuby's OpenSSL gem
http://www.jruby.org
Other
45 stars 80 forks source link

NoMethodError: undefined method `[]' for #<OpenSSL::ASN1::Sequence:0x696d109b> #268

Closed HoneyryderChuck closed 5 months ago

HoneyryderChuck commented 1 year ago

Coming from https://gitlab.com/honeyryderchuck/rodauth-oauth/-/jobs/3161911378

/builds/honeyryderchuck/rodauth-oauth/vendor/jruby/2.6.0/gems/json-jwt-1.16.0/lib/json/jwk.rb:126:in `to_rsa_key'
    /builds/honeyryderchuck/rodauth-oauth/vendor/jruby/2.6.0/gems/json-jwt-1.16.0/lib/json/jwk.rb:43:in `to_key'
    /builds/honeyryderchuck/rodauth-oauth/vendor/jruby/2.6.0/gems/json-jwt-1.16.0/lib/json/jose.rb:27:in `with_jwk_support'
    /builds/honeyryderchuck/rodauth-oauth/vendor/jruby/2.6.0/gems/json-jwt-1.16.0/lib/json/jws.rb:100:in `sign'
    /builds/honeyryderchuck/rodauth-oauth/vendor/jruby/2.6.0/gems/json-jwt-1.16.0/lib/json/jws.rb:17:in `sign!'
    /builds/honeyryderchuck/rodauth-oauth/vendor/jruby/2.6.0/gems/json-jwt-1.16.0/lib/json/jwt.rb:41:in `sign'
    /builds/honeyryderchuck/rodauth-oauth/lib/rodauth/features/oauth_jwt_base.rb:170:in `jwt_encode'

ASN1 sequences should behave like arrays.

kares commented 5 months ago

I do not see the Sequence#[] method available in recent Ruby, so it's likely a different issue in this case...

ruby -v -ropenssl -e 'pp ::OpenSSL::ASN1::Sequence([::OpenSSL::ASN1::Integer(111)])[0]'

ruby 3.1.4p223 (2023-03-30 revision 957bb7cb81) [x86_64-linux]
-e:1:in `<main>': undefined method `[]' for #<OpenSSL::ASN1::Sequence:0x000077c90c9c6560 @tag=16, @value=[#<OpenSSL::ASN1::Integer:0x000077c90c9c6628 @tag=2, @value=111, @tagging=nil, @tag_class=:UNIVERSAL, @indefinite_length=false>], @tagging=nil, @tag_class=:UNIVERSAL, @indefinite_length=false> (NoMethodError)

pp ::OpenSSL::ASN1::Sequence([::OpenSSL::ASN1::Integer(111)])[0]
                                                             ^^^