From a4a3ecf1f71f66bdb6441c4cb9666293a6c856af Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Wed, 15 May 2024 14:24:33 +0100 Subject: [PATCH] unify how taggedobjects get decoded --- src/main/java/org/jruby/ext/openssl/ASN1.java | 23 ++++++++----------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/src/main/java/org/jruby/ext/openssl/ASN1.java b/src/main/java/org/jruby/ext/openssl/ASN1.java index 8d579492..75b4a5dc 100644 --- a/src/main/java/org/jruby/ext/openssl/ASN1.java +++ b/src/main/java/org/jruby/ext/openssl/ASN1.java @@ -1063,21 +1063,18 @@ else if ( obj instanceof ASN1GraphicString ) { break; } - if (taggedObj.getTagClass() == BERTags.APPLICATION) { - try { - final ASN1Sequence sequence = (ASN1Sequence) taggedObj.getBaseUniversal(false, SEQUENCE); - @SuppressWarnings("unchecked") - final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects()); - return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK); - } catch (IllegalStateException e) { - IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject()).callMethod(context, "value"); - return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { val, tag, tag_class }, Block.NULL_BLOCK); - } - } else { - IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject()); - final RubyArray valArr = runtime.newArray(val); + try { + final ASN1Sequence sequence = (ASN1Sequence) taggedObj.getBaseUniversal(false, SEQUENCE); + @SuppressWarnings("unchecked") + final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects()); + System.out.println("arrayig"); return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK); + } catch (IllegalStateException e) { + System.out.println("rolled over"); + IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject()).callMethod(context, "value"); + return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { val, tag, tag_class }, Block.NULL_BLOCK); } + } if ( obj instanceof ASN1Sequence ) {