Skip to content

Commit cb1fdf8

Browse files
committed
support passing ssl_version as an argument to initialize SSLContext.new(:SSL_v3)
1 parent 1b18710 commit cb1fdf8

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,7 @@ public SSLContext(Ruby runtime, RubyClass type) {
265265

266266
@JRubyMethod(rest = true, visibility = Visibility.PRIVATE)
267267
public IRubyObject initialize(IRubyObject[] args) {
268+
if ( args.length > 0 ) set_ssl_version(args[0]);
268269
return this;
269270
}
270271

src/test/ruby/ssl/test_context.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ def test_methods
1111
assert ! methods.include?(:'TLSv1.1')
1212
end
1313

14+
def test_context_new
15+
OpenSSL::SSL::SSLContext.new
16+
17+
OpenSSL::SSL::SSLContext.new :SSLv3
18+
assert_raises ArgumentError do
19+
OpenSSL::SSL::SSLContext.new "TLSv42"
20+
end
21+
end
22+
1423
def test_context_set_ssl_version
1524
context = OpenSSL::SSL::SSLContext.new
1625
context.ssl_version = "TLSv1"

0 commit comments

Comments
 (0)