Skip to content

Commit d173700

Browse files
committed
x509store: emit warning if arguments are given to X509::Store.new
Anything passed to OpenSSL::X509::Store.new was always ignored. Let's emit an explicit warning to not confuse users.
1 parent fb2fcbb commit d173700

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

ext/openssl/ossl_x509store.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ ossl_x509store_initialize(int argc, VALUE *argv, VALUE self)
192192
{
193193
X509_STORE *store;
194194

195-
/* BUG: This method takes any number of arguments but appears to ignore them. */
196195
GetX509Store(self, store);
196+
if (argc != 0)
197+
rb_warn("OpenSSL::X509::Store.new does not take any arguments");
197198
#if !defined(HAVE_OPAQUE_OPENSSL)
198199
/* [Bug #405] [Bug #1678] [Bug #3000]; already fixed? */
199200
store->ex_data.sk = NULL;

test/openssl/test_x509store.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,11 @@ def setup
1616
@ee2 = OpenSSL::X509::Name.parse("/DC=org/DC=ruby-lang/CN=EE2")
1717
end
1818

19-
def test_nosegv_on_cleanup
20-
cert = OpenSSL::X509::Certificate.new
21-
store = OpenSSL::X509::Store.new
22-
ctx = OpenSSL::X509::StoreContext.new(store, cert, [])
23-
EnvUtil.suppress_warning do
24-
ctx.cleanup
25-
end
26-
ctx.verify
19+
def test_store_new
20+
# v2.3.0 emits explicit warning
21+
assert_warning(/new does not take any arguments/) {
22+
OpenSSL::X509::Store.new(123)
23+
}
2724
end
2825

2926
def test_add_file_path
@@ -255,6 +252,14 @@ def test_dup
255252
ctx = OpenSSL::X509::StoreContext.new(store)
256253
assert_raise(NoMethodError) { ctx.dup }
257254
end
255+
256+
def test_ctx_cleanup
257+
# Deprecated in Ruby 1.9.3
258+
cert = OpenSSL::X509::Certificate.new
259+
store = OpenSSL::X509::Store.new
260+
ctx = OpenSSL::X509::StoreContext.new(store, cert, [])
261+
assert_warning(/cleanup/) { ctx.cleanup }
262+
end
258263
end
259264

260265
end

0 commit comments

Comments
 (0)