@@ -1072,24 +1072,23 @@ else if ( obj instanceof DERBMPString ) {
1072
1072
return ASN1 .getClass ("ObjectId" ).newInstance (context , runtime .newString (objId ), Block .NULL_BLOCK );
1073
1073
}
1074
1074
1075
- if ( obj instanceof ASN1ApplicationSpecific ) { // TODO this will likely break in BC version > 1.71
1076
- final ASN1ApplicationSpecific appSpecific = (ASN1ApplicationSpecific ) obj ;
1077
- IRubyObject tag = runtime .newFixnum ( appSpecific .getApplicationTag () );
1078
- IRubyObject tag_class = runtime .newSymbol ("APPLICATION" );
1079
- final ASN1Sequence sequence = (ASN1Sequence ) appSpecific .getObject (SEQUENCE );
1080
- @ SuppressWarnings ("unchecked" )
1081
- final RubyArray valArr = decodeObjects (context , ASN1 , sequence .getObjects ());
1082
- return ASN1 .getClass ("ASN1Data" ).newInstance (context , new IRubyObject [] { valArr , tag , tag_class }, Block .NULL_BLOCK );
1083
- }
1084
-
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
- }
1075
+ if (obj instanceof ASN1TaggedObject ) {
1076
+ final ASN1TaggedObject taggedObj = (ASN1TaggedObject ) obj ;
1077
+ if (taggedObj .getTagClass () == BERTags .APPLICATION ) {
1078
+ IRubyObject tag = runtime .newFixnum ( taggedObj .getTagNo () );
1079
+ IRubyObject tag_class = runtime .newSymbol ("APPLICATION" );
1080
+ final ASN1Sequence sequence = (ASN1Sequence ) taggedObj .getBaseUniversal (false , SEQUENCE );
1081
+ @ SuppressWarnings ("unchecked" )
1082
+ final RubyArray valArr = decodeObjects (context , ASN1 , sequence .getObjects ());
1083
+ return ASN1 .getClass ("ASN1Data" ).newInstance (context , new IRubyObject [] { valArr , tag , tag_class }, Block .NULL_BLOCK );
1084
+ } else {
1085
+ IRubyObject val = decodeObject (context , ASN1 , taggedObj .getBaseObject ());
1086
+ IRubyObject tag = runtime .newFixnum ( taggedObj .getTagNo () );
1087
+ IRubyObject tag_class = runtime .newSymbol ("CONTEXT_SPECIFIC" );
1088
+ final RubyArray valArr = runtime .newArray (val );
1089
+ return ASN1 .getClass ("ASN1Data" ).newInstance (context , new IRubyObject [] { valArr , tag , tag_class }, Block .NULL_BLOCK );
1090
+ }
1091
+ }
1093
1092
1094
1093
if ( obj instanceof ASN1Sequence ) {
1095
1094
@ SuppressWarnings ("unchecked" )
@@ -1696,13 +1695,13 @@ ASN1Encodable toASN1(final ThreadContext context) {
1696
1695
}
1697
1696
1698
1697
if ( type == DERGeneralString .class ) {
1699
- return DERGeneralString . getInstance ( val .asString ().getBytes () );
1698
+ return new DERGeneralString ( val .asString ().toString () );
1700
1699
}
1701
1700
if ( type == DERVisibleString .class ) {
1702
- return DERVisibleString . getInstance ( val .asString ().getBytes () );
1701
+ return new DERVisibleString ( val .asString ().toString () );
1703
1702
}
1704
1703
if ( type == DERNumericString .class ) {
1705
- return DERNumericString . getInstance ( val .asString ().getBytes () );
1704
+ return new DERNumericString ( val .asString ().toString () );
1706
1705
}
1707
1706
1708
1707
if ( val instanceof RubyString ) {
0 commit comments