Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby-openssl
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0e927fa4b907
Choose a base ref
...
head repository: jruby/jruby-openssl
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 98e43608d70a
Choose a head ref
  • 4 commits
  • 8 files changed
  • 1 contributor

Commits on May 16, 2018

  1. Verified

    This commit was signed with the committer’s verified signature.
    headius Charles Oliver Nutter
    Copy the full SHA
    aea89c5 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    headius Charles Oliver Nutter
    Copy the full SHA
    21eb5e3 View commit details

Commits on May 17, 2018

  1. fix java.version detection (hopefully for good) -> tuning old way

    Partially reverts commit f86bc0b.
    ... reverting since this didn't handle non-digits safely
    kares committed May 17, 2018

    Verified

    This commit was signed with the committer’s verified signature.
    headius Charles Oliver Nutter
    Copy the full SHA
    8376aaa View commit details
  2. Copy the full SHA
    98e4360 View commit details
135 changes: 66 additions & 69 deletions src/main/java/org/jruby/ext/openssl/ASN1.java
Original file line number Diff line number Diff line change
@@ -793,117 +793,118 @@ static ASN1ObjectIdentifier toObjectID(final String oid, final boolean silent)
}

@JRubyMethod(name="Boolean", module=true, rest=true)
public static IRubyObject fact_Boolean(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "Boolean", args);
public static IRubyObject fact_Boolean(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "Boolean", args);
}

@JRubyMethod(name="Integer", module=true, rest=true)
public static IRubyObject fact_Integer(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "Integer", args);
public static IRubyObject fact_Integer(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "Integer", args);
}

@JRubyMethod(name="Enumerated", module=true, rest=true)
public static IRubyObject fact_Enumerated(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "Enumerated", args);
public static IRubyObject fact_Enumerated(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "Enumerated", args);
}

@JRubyMethod(name="BitString", module=true, rest=true)
public static IRubyObject fact_BitString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "BitString", args);
public static IRubyObject fact_BitString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "BitString", args);
}

@JRubyMethod(name="OctetString", module=true, rest=true)
public static IRubyObject fact_OctetString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "OctetString", args);
public static IRubyObject fact_OctetString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "OctetString", args);
}

@JRubyMethod(name="UTF8String", module=true, rest=true)
public static IRubyObject fact_UTF8String(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "UTF8String", args);
public static IRubyObject fact_UTF8String(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "UTF8String", args);
}

@JRubyMethod(name="NumericString", module=true, rest=true)
public static IRubyObject fact_NumericString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "NumericString", args);
public static IRubyObject fact_NumericString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "NumericString", args);
}

@JRubyMethod(name="PrintableString", module=true, rest=true)
public static IRubyObject fact_PrintableString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "PrintableString", args);
public static IRubyObject fact_PrintableString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "PrintableString", args);
}

@JRubyMethod(name="T61String", module=true, rest=true)
public static IRubyObject fact_T61String(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "T61String", args);
public static IRubyObject fact_T61String(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "T61String", args);
}

@JRubyMethod(name="VideotexString", module=true, rest=true)
public static IRubyObject fact_VideotexString(IRubyObject recv, IRubyObject[] args) {
return ((RubyModule)recv).getClass("VideotexString").callMethod(recv.getRuntime().getCurrentContext(),"new",args);
public static IRubyObject fact_VideotexString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "VideotexString", args);
}

@JRubyMethod(name="IA5String", module=true, rest=true)
public static IRubyObject fact_IA5String(IRubyObject recv, IRubyObject[] args) {
return ((RubyModule)recv).getClass("IA5String").callMethod(recv.getRuntime().getCurrentContext(),"new",args);
public static IRubyObject fact_IA5String(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "IA5String", args);
}

@JRubyMethod(name="GraphicString", module=true, rest=true)
public static IRubyObject fact_GraphicString(IRubyObject recv, IRubyObject[] args) {
return ((RubyModule)recv).getClass("GraphicString").callMethod(recv.getRuntime().getCurrentContext(),"new",args);
public static IRubyObject fact_GraphicString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "GraphicString", args);
}

@JRubyMethod(name="ISO64String", module=true, rest=true)
public static IRubyObject fact_ISO64String(IRubyObject recv, IRubyObject[] args) {
return ((RubyModule)recv).getClass("ISO64String").callMethod(recv.getRuntime().getCurrentContext(),"new",args);
public static IRubyObject fact_ISO64String(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "ISO64String", args);
}

@JRubyMethod(name="GeneralString", module=true, rest=true)
public static IRubyObject fact_GeneralString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "GeneralString", args);
public static IRubyObject fact_GeneralString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "GeneralString", args);
}

@JRubyMethod(name="UniversalString", module=true, rest=true)
public static IRubyObject fact_UniversalString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "UniversalString", args);
public static IRubyObject fact_UniversalString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "UniversalString", args);
}

@JRubyMethod(name="BMPString", module=true, rest=true)
public static IRubyObject fact_BMPString(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "BMPString", args);
public static IRubyObject fact_BMPString(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "BMPString", args);
}

@JRubyMethod(name="Nul", module=true, rest=true)
public static IRubyObject fact_Null(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "Null", args);
public static IRubyObject fact_Null(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "Null", args);
}

@JRubyMethod(name="ObjectId", module=true, rest=true)
public static IRubyObject fact_ObjectId(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "ObjectId", args);
public static IRubyObject fact_ObjectId(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "ObjectId", args);
}

@JRubyMethod(name="UTCTime", module=true, rest=true)
public static IRubyObject fact_UTCTime(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "UTCTime", args);
public static IRubyObject fact_UTCTime(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "UTCTime", args);
}

@JRubyMethod(name="GeneralizedTime", module=true, rest=true)
public static IRubyObject fact_GeneralizedTime(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "GeneralizedTime", args);
public static IRubyObject fact_GeneralizedTime(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "GeneralizedTime", args);
}

@JRubyMethod(name="Sequence", module=true, rest=true)
public static IRubyObject fact_Sequence(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "Sequence", args);
public static IRubyObject fact_Sequence(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "Sequence", args);
}

@JRubyMethod(name="Set", module=true, rest=true)
public static IRubyObject fact_Set(IRubyObject self, IRubyObject[] args) {
return callClassNew(self, "Set", args);
public static IRubyObject fact_Set(ThreadContext context, IRubyObject self, IRubyObject[] args) {
return newInstance(context, self, "Set", args);
}

private static IRubyObject callClassNew(final IRubyObject self, final String className, final IRubyObject[] args) {
return ((RubyModule) self).getClass(className).callMethod(self.getRuntime().getCurrentContext(), "new", args);
private static IRubyObject newInstance(final ThreadContext context, final IRubyObject parent,
final String className, final IRubyObject[] args) {
return ((RubyModule) parent).getClass(className).newInstance(context, args, Block.NULL_BLOCK);
}

public static class ObjectId {
@@ -964,17 +965,17 @@ static IRubyObject decodeObject(final ThreadContext context,

if ( obj instanceof ASN1Integer ) {
final BN val = BN.newBN(runtime, ((ASN1Integer) obj).getValue());
return ASN1.getClass("Integer").callMethod(context, "new", val);
return ASN1.getClass("Integer").newInstance(context, val, Block.NULL_BLOCK);
}
if ( obj instanceof DERInteger ) {
final BN val = BN.newBN(runtime, ((DERInteger) obj).getValue());
return ASN1.getClass("Integer").callMethod(context, "new", val);
return ASN1.getClass("Integer").newInstance(context, val, Block.NULL_BLOCK);
}

if ( obj instanceof DERBitString ) {
final DERBitString derObj = (DERBitString) obj;
RubyString str = runtime.newString( new ByteList(derObj.getBytes(), false) );
IRubyObject bitString = ASN1.getClass("BitString").callMethod(context, "new", str);
IRubyObject bitString = ASN1.getClass("BitString").newInstance(context, str, Block.NULL_BLOCK);
bitString.callMethod(context, "unused_bits=", runtime.newFixnum( derObj.getPadBits() ));
return bitString;
}
@@ -1016,7 +1017,7 @@ else if ( obj instanceof DERBMPString ) {
}
bytes = ByteList.create(((ASN1String) obj).getString());
}
return ASN1.getClass(type).callMethod(context, "new", runtime.newString(bytes));
return ASN1.getClass(type).newInstance(context, runtime.newString(bytes), Block.NULL_BLOCK);
}

//if ( obj instanceof DEROctetString ) {
@@ -1028,44 +1029,44 @@ else if ( obj instanceof DERBMPString ) {
final ByteList octets = new ByteList(((ASN1OctetString) obj).getOctets(), false);
// NOTE: sometimes MRI does include the tag but it really should not ;( !
//final ByteList octets = new ByteList(((ASN1OctetString) obj).getEncoded(ASN1Encoding.DER), false);
return ASN1.getClass("OctetString").callMethod(context, "new", runtime.newString(octets));
return ASN1.getClass("OctetString").newInstance(context, runtime.newString(octets), Block.NULL_BLOCK);
}

if ( obj instanceof ASN1Null ) {
return ASN1.getClass("Null").callMethod(context,"new", runtime.getNil());
return ASN1.getClass("Null").newInstance(context, runtime.getNil(), Block.NULL_BLOCK);
}
if ( obj instanceof ASN1Boolean ) {
final boolean val = ((ASN1Boolean) obj).isTrue();
return ASN1.getClass("Boolean").callMethod(context, "new", runtime.newBoolean(val));
return ASN1.getClass("Boolean").newInstance(context, runtime.newBoolean(val), Block.NULL_BLOCK);
}
// DERBoolean extends ASN1Boolean only since 1.51 (<= 1.50 the other way around)
if ( obj instanceof DERBoolean ) {
final boolean val = ((DERBoolean) obj).isTrue();
return ASN1.getClass("Boolean").callMethod(context, "new", runtime.newBoolean(val));
return ASN1.getClass("Boolean").newInstance(context, runtime.newBoolean(val), Block.NULL_BLOCK);
}

if ( obj instanceof ASN1UTCTime ) {
final Date adjustedTime;
try { adjustedTime = ((ASN1UTCTime) obj).getAdjustedDate(); }
catch (ParseException e) { throw new IOException(e); }
final RubyTime time = RubyTime.newTime(runtime, adjustedTime.getTime());
return ASN1.getClass("UTCTime").callMethod(context,"new", time);
return ASN1.getClass("UTCTime").newInstance(context, time, Block.NULL_BLOCK);
}
// NOTE: keep for BC versions compatibility ... extends ASN1UTCTime (since BC 1.51)
if ( obj instanceof DERUTCTime ) {
final Date adjustedTime;
try { adjustedTime = ((DERUTCTime) obj).getAdjustedDate(); }
catch (ParseException e) { throw new IOException(e); }
final RubyTime time = RubyTime.newTime(runtime, adjustedTime.getTime());
return ASN1.getClass("UTCTime").callMethod(context,"new", time);
return ASN1.getClass("UTCTime").newInstance(context, time, Block.NULL_BLOCK);
}

if ( obj instanceof ASN1GeneralizedTime ) {
final Date generalTime;
try { generalTime = ((ASN1GeneralizedTime) obj).getDate(); }
catch (ParseException e) { throw new IOException(e); }
final RubyTime time = RubyTime.newTime(runtime, generalTime.getTime());
return ASN1.getClass("GeneralizedTime").callMethod(context,"new", time);
return ASN1.getClass("GeneralizedTime").newInstance(context, time, Block.NULL_BLOCK);
}
// NOTE: keep for BC versions compatibility ... extends ASN1GeneralizedTime (since BC 1.51)
if ( obj instanceof DERGeneralizedTime ) {
@@ -1075,18 +1076,18 @@ else if ( obj instanceof DERBMPString ) {
}
catch (ParseException e) { throw new IOException(e); }
final RubyTime time = RubyTime.newTime(runtime, generalTime.getTime());
return ASN1.getClass("GeneralizedTime").callMethod(context,"new", time);
return ASN1.getClass("GeneralizedTime").newInstance(context, time, Block.NULL_BLOCK);
}

if ( obj instanceof ASN1ObjectIdentifier ) {
final String objId = ((ASN1ObjectIdentifier) obj).getId();
return ASN1.getClass("ObjectId").callMethod(context, "new", runtime.newString(objId));
return ASN1.getClass("ObjectId").newInstance(context, runtime.newString(objId), Block.NULL_BLOCK);
}
// ASN1ObjectIdentifier extends DERObjectIdentifier < 1.51
// DERObjectIdentifier extends ASN1ObjectIdentifier = 1.51
if ( obj instanceof DERObjectIdentifier ) {
final String objId = ((DERObjectIdentifier) obj).getId();
return ASN1.getClass("ObjectId").callMethod(context, "new", runtime.newString(objId));
return ASN1.getClass("ObjectId").newInstance(context, runtime.newString(objId), Block.NULL_BLOCK);
}

if ( obj instanceof ASN1TaggedObject ) {
@@ -1095,9 +1096,7 @@ else if ( obj instanceof DERBMPString ) {
IRubyObject tag = runtime.newFixnum( taggedObj.getTagNo() );
IRubyObject tag_class = runtime.newSymbol("CONTEXT_SPECIFIC");
final RubyArray valArr = runtime.newArray(val);
return ASN1.getClass("ASN1Data").callMethod(context, "new",
new IRubyObject[] { valArr, tag, tag_class }
);
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
}

if ( obj instanceof DERApplicationSpecific ) {
@@ -1107,25 +1106,23 @@ else if ( obj instanceof DERBMPString ) {
final ASN1Sequence sequence = (ASN1Sequence) appSpecific.getObject(SEQUENCE);
@SuppressWarnings("unchecked")
final RubyArray valArr = decodeObjects(context, ASN1, sequence.getObjects());
return ASN1.getClass("ASN1Data").callMethod(context, "new",
new IRubyObject[] { valArr, tag, tag_class }
);
return ASN1.getClass("ASN1Data").newInstance(context, new IRubyObject[] { valArr, tag, tag_class }, Block.NULL_BLOCK);
}

if ( obj instanceof ASN1Sequence ) {
@SuppressWarnings("unchecked")
RubyArray arr = decodeObjects(context, ASN1, ((ASN1Sequence) obj).getObjects());
return ASN1.getClass("Sequence").callMethod(context, "new", arr);
return ASN1.getClass("Sequence").newInstance(context, arr, Block.NULL_BLOCK);
}
if ( obj instanceof ASN1Set ) {
@SuppressWarnings("unchecked")
RubyArray arr = decodeObjects(context, ASN1, ((ASN1Set) obj).getObjects());
return ASN1.getClass("Set").callMethod(context, "new", arr);
return ASN1.getClass("Set").newInstance(context, arr, Block.NULL_BLOCK);
}

if ( obj instanceof ASN1Enumerated ) {
final RubyInteger value = RubyBignum.bignorm(runtime, ((ASN1Enumerated) obj).getValue());
return ASN1.getClass("Enumerated").callMethod(context, "new", value);
return ASN1.getClass("Enumerated").newInstance(context, value, Block.NULL_BLOCK);
}

throw new IllegalArgumentException("unable to decode object: " + obj + " (" + ( obj == null ? "" : obj.getClass().getName() ) + ")");
Loading