From 524245a58018cdc44d7c785247e0b2786201e097 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 | 20 +++++++------------ 1 file changed, 7 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..f158642e 100644 --- a/src/main/java/org/jruby/ext/openssl/ASN1.java +++ b/src/main/java/org/jruby/ext/openssl/ASN1.java @@ -1063,20 +1063,14 @@ 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()); 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); } }