From 14b06b0e7fff356bcd1c11a111afa68baacc9c41 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Sat, 20 Aug 2022 14:56:06 +0100 Subject: [PATCH] to_der on ASN1Data should convert ruby strings into java strings before encoding --- src/test/ruby/test_asn1.rb | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/ruby/test_asn1.rb b/src/test/ruby/test_asn1.rb index 95f55137..cb697c08 100644 --- a/src/test/ruby/test_asn1.rb +++ b/src/test/ruby/test_asn1.rb @@ -21,6 +21,16 @@ def test_encode_integer assert_equal i, OpenSSL::ASN1.decode(ai.to_der).value end + def test_encode_asn1_data + ai = OpenSSL::ASN1::ASN1Data.new(i = "bla", 0, :APPLICATION) + assert_equal i, OpenSSL::ASN1.decode(ai.to_der).value + + ai = OpenSSL::ASN1::ASN1Data.new(i = ["bla"], 0, :APPLICATION) + assert_equal i, OpenSSL::ASN1.decode(ai.to_der).value + + assert_raise(TypeError) { OpenSSL::ASN1::ASN1Data.new(1).to_der } + end + def test_encode_nil #Primitives raise TypeError, Constructives NoMethodError