diff --git a/src/main/java/org/jruby/ext/openssl/ASN1.java b/src/main/java/org/jruby/ext/openssl/ASN1.java index fbe08bb9..bf845d4a 100644 --- a/src/main/java/org/jruby/ext/openssl/ASN1.java +++ b/src/main/java/org/jruby/ext/openssl/ASN1.java @@ -1072,14 +1072,16 @@ else if ( obj instanceof DERBMPString ) { return ASN1.getClass("ObjectId").newInstance(context, runtime.newString(objId), Block.NULL_BLOCK); } - if ( obj instanceof ASN1ApplicationSpecific ) { // TODO this will likely break in BC version > 1.71 - final ASN1ApplicationSpecific appSpecific = (ASN1ApplicationSpecific) obj; - IRubyObject tag = runtime.newFixnum( appSpecific.getApplicationTag() ); - IRubyObject tag_class = runtime.newSymbol("APPLICATION"); - final ASN1Sequence sequence = (ASN1Sequence) appSpecific.getObject(SEQUENCE); - @SuppressWarnings("unchecked") - final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects()); - return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK); + if (obj instanceof ASN1TaggedObject) { + final ASN1TaggedObject taggedObj = (ASN1TaggedObject) obj; + if (taggedObj.getTagClass() == BERTags.APPLICATION) { + IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() ); + IRubyObject tag_class = runtime.newSymbol("APPLICATION"); + final ASN1Sequence sequence = (ASN1Sequence) taggedObj.getBaseUniversal(true, SEQUENCE); + @SuppressWarnings("unchecked") + final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects()); + return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK); + } } if ( obj instanceof ASN1TaggedObject ) { @@ -1696,13 +1698,13 @@ ASN1Encodable toASN1(final ThreadContext context) { } if ( type == DERGeneralString.class ) { - return DERGeneralString.getInstance( val.asString().getBytes() ); + return new DERGeneralString( val.asString().toString() ); } if ( type == DERVisibleString.class ) { - return DERVisibleString.getInstance( val.asString().getBytes() ); + return new DERVisibleString( val.asString().toString() ); } if ( type == DERNumericString.class ) { - return DERNumericString.getInstance( val.asString().getBytes() ); + return new DERNumericString( val.asString().toString() ); } if ( val instanceof RubyString ) { diff --git a/src/main/java/org/jruby/ext/openssl/X509Extension.java b/src/main/java/org/jruby/ext/openssl/X509Extension.java index c199d05b..b50f0ca5 100644 --- a/src/main/java/org/jruby/ext/openssl/X509Extension.java +++ b/src/main/java/org/jruby/ext/openssl/X509Extension.java @@ -38,6 +38,7 @@ import org.bouncycastle.asn1.ASN1EncodableVector; import org.bouncycastle.asn1.ASN1Encoding; import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.ASN1IA5String; import org.bouncycastle.asn1.ASN1Object; import org.bouncycastle.asn1.ASN1ObjectIdentifier; import org.bouncycastle.asn1.ASN1OctetString; @@ -46,7 +47,6 @@ import org.bouncycastle.asn1.ASN1String; import org.bouncycastle.asn1.ASN1TaggedObject; import org.bouncycastle.asn1.BERTags; -import org.bouncycastle.asn1.DERIA5String; import org.bouncycastle.asn1.DEROctetString; import org.bouncycastle.asn1.DERUniversalString; import org.bouncycastle.asn1.DLSequence; @@ -620,7 +620,7 @@ private static boolean formatGeneralName(final GeneralName name, final ByteList case GeneralName.uniformResourceIdentifier: if ( ! tagged ) out.append('U').append('R').append('I'). append(':'); - val = DERIA5String.getInstance(obj).getString(); + val = ASN1IA5String.getInstance(obj).getString(); out.append( ByteList.plain(val) ); break; case GeneralName.directoryName: diff --git a/src/main/java/org/jruby/ext/openssl/impl/PKey.java b/src/main/java/org/jruby/ext/openssl/impl/PKey.java index d54d5817..d2534ade 100644 --- a/src/main/java/org/jruby/ext/openssl/impl/PKey.java +++ b/src/main/java/org/jruby/ext/openssl/impl/PKey.java @@ -67,7 +67,6 @@ import org.bouncycastle.asn1.DLSequence; import org.bouncycastle.asn1.pkcs.PKCSObjectIdentifiers; import org.bouncycastle.asn1.pkcs.PrivateKeyInfo; -import org.bouncycastle.asn1.sec.ECPrivateKeyStructure; import org.bouncycastle.asn1.x509.AlgorithmIdentifier; import org.bouncycastle.asn1.x509.DSAParameter; import org.bouncycastle.asn1.x509.SubjectPublicKeyInfo;