Skip to content

Commit 41521e8

Browse files
committed
[compat] undefine clone on Store and StoreContext
1 parent b731047 commit 41521e8

3 files changed

Lines changed: 9 additions & 0 deletions

File tree

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

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

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

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
@@ -134,6 +134,13 @@ def test_add_crl_type_check
134134
assert_raise(TypeError) { store.add_crl(nil) }
135135
end
136136

137+
# CRuby undefs initialize_copy, blocking both dup and clone
138+
def test_store_dup_clone_not_allowed
139+
store = OpenSSL::X509::Store.new
140+
assert_raise(NoMethodError) { store.dup }
141+
assert_raise(NoMethodError) { store.clone }
142+
end
143+
137144
def test_use_non_existing_cert_file
138145
ENV['SSL_CERT_FILE'] = 'non-existing-file.crt'
139146
store = OpenSSL::X509::Store.new

0 commit comments

Comments
 (0)