Skip to content

[fix] try value#to_der when creating ASN.1 sequence #283

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

skunkworker
Copy link
Contributor

@skunkworker skunkworker commented Aug 15, 2023

Could fix #282

I noticed that there is an expectation that anything inside of an ASN1 object is either a RubyArray or a object that responds to [] this checks to see if the sub object responds to #to_der and calls that method. I was unable to get the test suite to run locally on my M1 pro, and would like to be able to test on here using the suites.

Works and doesn't work before this PR.

Works

data_sequence = ::OpenSSL::ASN1::Sequence([::OpenSSL::ASN1::Integer(0)])
asn1 = ::OpenSSL::ASN1::Sequence([data_sequence])
asn1.to_der

Doesn't work but should

data_sequence = ::OpenSSL::ASN1::Sequence([::OpenSSL::ASN1::Integer(0)])
asn1 = ::OpenSSL::ASN1::Sequence(data_sequence)
asn1.to_der

@kares kares changed the title call to_der when trying to call on a singular unwrapped object [fix] try value#to_der when creating ASN.1 sequence Feb 13, 2024
@kares
Copy link
Member

kares commented Feb 13, 2024

have rebased locally, the test unfortunately fail so seems like more investigation will be needed due 🔴

Failure: test_encode_nested_sequence_to_der(TestASN1)
/oss/jruby-openssl/src/test/ruby/test_asn1.rb:27:in `test_encode_nested_sequence_to_der'
     24:   def test_encode_nested_sequence_to_der
     25:     data_sequence = ::OpenSSL::ASN1::Sequence([::OpenSSL::ASN1::Integer(0)])
     26:     asn1 = ::OpenSSL::ASN1::Sequence(data_sequence)
  => 27:     assert_equal "0\x03\x02\x01\x00", asn1.to_der
     28:   end
     29: 
     30:   def test_encode_nested_set_to_der
org/jruby/RubyKernel.java:1310:in `catch'
org/jruby/RubyKernel.java:1305:in `catch'
org/jruby/RubyKernel.java:1310:in `catch'
org/jruby/RubyKernel.java:1305:in `catch'
<"0\x03\x02\x01\x00">(US-ASCII) expected but was
<"0\x050\x03\x02\x01\x00">(ASCII-8BIT)


a test output (from https://github.com/jruby/jruby-openssl/tree/test-pr-283)

@kares
Copy link
Member

kares commented Apr 11, 2024

the original issue has been fixed, I have included the test case from the PR on master: ceeacba

@kares kares closed this Apr 11, 2024
@skunkworker
Copy link
Contributor Author

the original issue has been fixed, I have included the test case from the PR on master: ceeacba

Thanks for adding that, it is very appreciated.

@skunkworker skunkworker deleted the call_to_der_on_nested_object branch April 12, 2024 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling .to_der raises " undefined method `[]' for #<OpenSSL::ASN1::Sequence>" error
2 participants