@@ -1072,14 +1072,16 @@ 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 );
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 (true , 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
+ }
1083
1085
}
1084
1086
1085
1087
if ( obj instanceof ASN1TaggedObject ) {
@@ -1696,13 +1698,13 @@ ASN1Encodable toASN1(final ThreadContext context) {
1696
1698
}
1697
1699
1698
1700
if ( type == DERGeneralString .class ) {
1699
- return DERGeneralString . getInstance ( val .asString ().getBytes () );
1701
+ return new DERGeneralString ( val .asString ().toString () );
1700
1702
}
1701
1703
if ( type == DERVisibleString .class ) {
1702
- return DERVisibleString . getInstance ( val .asString ().getBytes () );
1704
+ return new DERVisibleString ( val .asString ().toString () );
1703
1705
}
1704
1706
if ( type == DERNumericString .class ) {
1705
- return DERNumericString . getInstance ( val .asString ().getBytes () );
1707
+ return new DERNumericString ( val .asString ().toString () );
1706
1708
}
1707
1709
1708
1710
if ( val instanceof RubyString ) {
0 commit comments