@@ -1072,10 +1072,15 @@ else if ( obj instanceof ASN1GraphicString ) {
1072
1072
}
1073
1073
1074
1074
if (taggedObj .getTagClass () == BERTags .APPLICATION ) {
1075
- final ASN1Sequence sequence = (ASN1Sequence ) taggedObj .getBaseUniversal (false , SEQUENCE );
1076
- @ SuppressWarnings ("unchecked" )
1077
- final RubyArray valArr = decodeObjects (context , ASN1 , sequence .getObjects ());
1078
- return ASN1 .getClass ("ASN1Data" ).newInstance (context , new IRubyObject [] { valArr , tag , tag_class }, Block .NULL_BLOCK );
1075
+ try {
1076
+ final ASN1Sequence sequence = (ASN1Sequence ) taggedObj .getBaseUniversal (false , SEQUENCE );
1077
+ @ SuppressWarnings ("unchecked" )
1078
+ final RubyArray valArr = decodeObjects (context , ASN1 , sequence .getObjects ());
1079
+ return ASN1 .getClass ("ASN1Data" ).newInstance (context , new IRubyObject [] { valArr , tag , tag_class }, Block .NULL_BLOCK );
1080
+ } catch (IllegalStateException e ) {
1081
+ IRubyObject val = decodeObject (context , ASN1 , taggedObj .getBaseObject ()).callMethod (context , "value" );
1082
+ return ASN1 .getClass ("ASN1Data" ).newInstance (context , new IRubyObject [] { val , tag , tag_class }, Block .NULL_BLOCK );
1083
+ }
1079
1084
} else {
1080
1085
IRubyObject val = decodeObject (context , ASN1 , taggedObj .getBaseObject ());
1081
1086
final RubyArray valArr = runtime .newArray (val );
@@ -1444,11 +1449,6 @@ final ASN1TaggedObject toASN1TaggedObject(final ThreadContext context) {
1444
1449
throw context .runtime .newTypeError (
1445
1450
"no implicit conversion of " + value .getMetaClass ().getBaseName () + " into String" );
1446
1451
}
1447
-
1448
- if (!(value instanceof ASN1Data )) {
1449
- throw new UnsupportedOperationException ("toASN1 " + inspect () + " value: " + value .inspect () + " (" + value .getMetaClass () + ")" );
1450
- }
1451
- return new DERTaggedObject (isExplicitTagging (), tagClass , tag , ((ASN1Data ) value ).toASN1 (context ));
1452
1452
}
1453
1453
1454
1454
@ JRubyMethod
0 commit comments