Skip to content

Commit a90f7da

Browse files
committed
[fix] restore ASN1 application specific decoding behavior
1 parent 195d5a8 commit a90f7da

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/main/java/org/jruby/ext/openssl/ASN1.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,16 +1072,7 @@ else if ( obj instanceof DERBMPString ) {
10721072
return ASN1.getClass("ObjectId").newInstance(context, runtime.newString(objId), Block.NULL_BLOCK);
10731073
}
10741074

1075-
if ( obj instanceof ASN1TaggedObject ) {
1076-
final ASN1TaggedObject taggedObj = (ASN1TaggedObject) obj;
1077-
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject());
1078-
IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() );
1079-
IRubyObject tag_class = runtime.newSymbol("CONTEXT_SPECIFIC");
1080-
final RubyArray valArr = runtime.newArray(val);
1081-
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
1082-
}
1083-
1084-
if ( obj instanceof ASN1ApplicationSpecific ) {
1075+
if ( obj instanceof ASN1ApplicationSpecific ) { // TODO this will likely break in BC version > 1.71
10851076
final ASN1ApplicationSpecific appSpecific = (ASN1ApplicationSpecific) obj;
10861077
IRubyObject tag = runtime.newFixnum( appSpecific.getApplicationTag() );
10871078
IRubyObject tag_class = runtime.newSymbol("APPLICATION");
@@ -1091,6 +1082,15 @@ else if ( obj instanceof DERBMPString ) {
10911082
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
10921083
}
10931084

1085+
if ( obj instanceof ASN1TaggedObject ) {
1086+
final ASN1TaggedObject taggedObj = (ASN1TaggedObject) obj;
1087+
IRubyObject val = decodeObject(context, ASN1, taggedObj.getBaseObject());
1088+
IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() );
1089+
IRubyObject tag_class = runtime.newSymbol("CONTEXT_SPECIFIC");
1090+
final RubyArray valArr = runtime.newArray(val);
1091+
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
1092+
}
1093+
10941094
if ( obj instanceof ASN1Sequence ) {
10951095
@SuppressWarnings("unchecked")
10961096
RubyArray arr = decodeObjects(context, ASN1, ((ASN1Sequence) obj).getObjects());

0 commit comments

Comments
 (0)