Skip to content

Commit e40b37a

Browse files
fixed decoding logic for EndOfContent object
1 parent 2585b09 commit e40b37a

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,10 +1170,6 @@ private static IRubyObject decodeImpl(final ThreadContext context, final RubyMod
11701170
int offset = in.offset();
11711171
final int tag = asn1[offset] & 0xFF;
11721172

1173-
if ( ( tag & BERTags.CONSTRUCTED ) == 0 ) {
1174-
return decodeObject(context, ASN1, readObject(in));
1175-
}
1176-
11771173
// NOTE: need to handle OpenSSL::ASN1::Constructive wrapping by hand :
11781174
int tagNo = tag & 0x1f;
11791175
if (tagNo == 0x1f)
@@ -1204,6 +1200,18 @@ private static IRubyObject decodeImpl(final ThreadContext context, final RubyMod
12041200
}
12051201
final int length = asn1[ ++offset ] & 0xFF;
12061202
final boolean isIndefiniteLength = length == 0x80;
1203+
1204+
1205+
if ( ( tag & BERTags.CONSTRUCTED ) == 0 ) {
1206+
if (tagNo == 0 && length == 0) {
1207+
in.read(); in.read();
1208+
return EndOfContent.newInstance(context);
1209+
}
1210+
1211+
return decodeObject(context, ASN1, readObject(in));
1212+
}
1213+
1214+
12071215
IRubyObject decoded;
12081216

12091217
decoded = decodeObject(context, ASN1, readObject(in));

0 commit comments

Comments
 (0)