Skip to content

Commit aae2576

Browse files
committed
[compat] undefine clone on Store and StoreContext
1 parent 9968234 commit aae2576

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ static void createX509Store(final Ruby runtime, final RubyModule X509, final Rub
6969
Store.addReadWriteAttribute(context, "chain");
7070
Store.defineAnnotatedMethods(X509Store.class);
7171
Store.undefineMethod("dup");
72+
Store.undefineMethod("clone");
7273

7374
X509StoreContext.createX509StoreContext(runtime, X509);
7475
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public static void createX509StoreContext(final Ruby runtime, final RubyModule X
6767
(r, klass) -> new X509StoreContext(r, klass));
6868
StoreContext.defineAnnotatedMethods(X509StoreContext.class);
6969
StoreContext.undefineMethod("dup");
70+
StoreContext.undefineMethod("clone");
7071
}
7172

7273
private static RubyClass _StoreContext(final Ruby runtime) {

src/test/ruby/x509/test_x509store.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,13 @@ def test_add_file_raises_with_invalid_pem # GH-285
101101
assert_raise(OpenSSL::X509::StoreError) { store.add_file(invalid) }
102102
end
103103

104+
# CRuby undefs initialize_copy, blocking both dup and clone
105+
def test_store_dup_clone_not_allowed
106+
store = OpenSSL::X509::Store.new
107+
assert_raise(NoMethodError) { store.dup }
108+
assert_raise(NoMethodError) { store.clone }
109+
end
110+
104111
def test_use_non_existing_cert_file
105112
ENV['SSL_CERT_FILE'] = 'non-existing-file.crt'
106113
store = OpenSSL::X509::Store.new

0 commit comments

Comments
 (0)