Skip to content

Commit 4365585

Browse files
committed
[feat] support to_java conversion for CRL
1 parent d9dc3f0 commit 4365585

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/main/java/org/jruby/ext/openssl/X509CRL.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,14 @@ public IRubyObject op_equal(ThreadContext context, IRubyObject obj) {
709709
return context.runtime.getFalse();
710710
}
711711

712+
@Override
713+
public Object toJava(Class target) {
714+
if (target.isAssignableFrom(java.security.cert.X509CRL.class)) {
715+
return getCRL();
716+
}
717+
return super.toJava(target);
718+
}
719+
712720
private static RubyClass _CRLError(final Ruby runtime) {
713721
return _X509(runtime).getClass("CRLError");
714722
}

src/test/ruby/x509/test_x509crl.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,12 @@ def test_extension
164164
assert_equal(false, exts[2].critical?)
165165
end
166166

167+
def test_to_java
168+
crl = OpenSSL::X509::CRL.new File.read(File.expand_path('../revoked.crl', __FILE__))
169+
assert_kind_of java.security.cert.X509CRL, crl.to_java
170+
assert_same crl.to_java, crl.to_java(java.security.cert.X509CRL)
171+
end
172+
167173
private
168174

169175
def get_subject_key_id(cert)

0 commit comments

Comments
 (0)