Skip to content

Commit 10421e1

Browse files
committed
[feat] support OpenSSL::Timestamp (#372)
1 parent 169b310 commit 10421e1

12 files changed

Lines changed: 1335 additions & 11 deletions

File tree

‎src/main/java/org/jruby/ext/openssl/ASN1.java‎

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ static ASN1ObjectIdentifier getObjectID(final Ruby runtime, final String nameOrO
755755
return new ASN1ObjectIdentifier( nameOrOid );
756756
}
757757

758-
static ASN1ObjectIdentifier toObjectID(final String oid, final boolean silent)
758+
private static ASN1ObjectIdentifier toObjectID(final String oid, final boolean silent)
759759
throws IllegalArgumentException {
760760
try {
761761
return new ASN1ObjectIdentifier(oid);
@@ -766,6 +766,11 @@ static ASN1ObjectIdentifier toObjectID(final String oid, final boolean silent)
766766
}
767767
}
768768

769+
static String shortName(final Ruby runtime, final ASN1ObjectIdentifier oid) {
770+
final String name = oid2name(runtime, oid, true);
771+
return name == null ? oid.getId() : name;
772+
}
773+
769774
@JRubyMethod(name="Boolean", module=true, rest=true)
770775
public static IRubyObject fact_Boolean(ThreadContext context, IRubyObject self, IRubyObject[] args) {
771776
return newInstance(context, self, "Boolean", args);
@@ -1554,7 +1559,7 @@ boolean isEoc() {
15541559
}
15551560

15561561
public static RaiseException newASN1Error(Ruby runtime, String message) {
1557-
return newError(runtime, _ASN1(runtime).getClass("ASN1Error"), message, false);
1562+
return newError(runtime, _ASN1Error(runtime), message, false);
15581563
}
15591564

15601565
static RaiseException newASN1Error(Ruby runtime, Throwable ex) {
@@ -1565,6 +1570,10 @@ static RubyModule _ASN1(final Ruby runtime) {
15651570
return (RubyModule) runtime.getModule("OpenSSL").getConstant("ASN1");
15661571
}
15671572

1573+
static RubyClass _ASN1Error(final Ruby runtime) {
1574+
return _ASN1(runtime).getClass("ASN1Error");
1575+
}
1576+
15681577
static org.bouncycastle.asn1.ASN1Primitive readObject(final byte[] bytes)
15691578
throws IOException {
15701579
return new ASN1InputStream(new ByteArrayInputStream(bytes)).readObject();

‎src/main/java/org/jruby/ext/openssl/OpenSSL.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public static void createOpenSSL(final Ruby runtime) {
106106
PKCS5.createPKCS5(runtime, _OpenSSL);
107107
OCSP.createOCSP(runtime, _OpenSSL, OpenSSLError);
108108
KDF.createKDF(runtime, _OpenSSL, OpenSSLError);
109+
Timestamp.createTimestamp(runtime, _OpenSSL, OpenSSLError);
109110

110111
runtime.getLoadService().require("jopenssl/version");
111112

‎src/main/java/org/jruby/ext/openssl/PKCS7.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public IRubyObject initialize(final ThreadContext context, IRubyObject[] args) {
314314
}
315315
return this;
316316
}
317+
317318
IRubyObject arg = to_der_if_possible(context, args[0]);
318319
BIO input = obj2bio(context, arg);
319320
try {

0 commit comments

Comments
 (0)