Skip to content

Commit 451ba1d

Browse files
committed
Support negotiating up to TLS1_1 and TLS1_2 when the server supports these ssl_versions
1 parent d030e6d commit 451ba1d

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ public class SSLContext extends RubyObject {
122122
SSL_VERSION_OSSL2JSSE.put("SSLv23", "SSL");
123123
SSL_VERSION_OSSL2JSSE.put("SSLv23_server", "SSL");
124124
SSL_VERSION_OSSL2JSSE.put("SSLv23_client", "SSL");
125-
ENABLED_PROTOCOLS.put("SSL", new String[] { "SSLv2", "SSLv3", "TLSv1" });
125+
ENABLED_PROTOCOLS.put("SSL", new String[] { "SSLv2", "SSLv3", "TLSv1", "TLSv1.1", "TLSv1.2" });
126126

127127
// Historically we were ahead of MRI to support TLS
128128
// ... thus the non-standard names version names :
129129

130130
SSL_VERSION_OSSL2JSSE.put("TLS", "TLS");
131-
ENABLED_PROTOCOLS.put("TLS", new String[] { "TLSv1", "TLSv1.1" });
131+
ENABLED_PROTOCOLS.put("TLS", new String[] { "TLSv1", "TLSv1.1", "TLSv1.2" });
132132

133133
SSL_VERSION_OSSL2JSSE.put("TLSv1.1", "TLSv1.1");
134134
ENABLED_PROTOCOLS.put("TLSv1.1", new String[] { "TLSv1.1" });

src/test/ruby/ssl/test_ssl.rb

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,29 @@ def test_ssl_version_tlsv1
9595
end
9696
end
9797

98+
def test_ssl_version_tlsv1_1
99+
ctx_proc = Proc.new do |ctx|
100+
ctx.ssl_version = "TLSv1_1"
101+
end
102+
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc) do |server, port|
103+
sock = TCPSocket.new("127.0.0.1", port)
104+
ssl = OpenSSL::SSL::SSLSocket.new(sock)
105+
ssl.connect
106+
assert_equal("TLSv1.1", ssl.ssl_version)
107+
ssl.close
108+
end
109+
end
110+
111+
def test_ssl_version_tlsv1_2
112+
ctx_proc = Proc.new do |ctx|
113+
ctx.ssl_version = "TLSv1_2"
114+
end
115+
start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc) do |server, port|
116+
sock = TCPSocket.new("127.0.0.1", port)
117+
ssl = OpenSSL::SSL::SSLSocket.new(sock)
118+
ssl.connect
119+
assert_equal("TLSv1.2", ssl.ssl_version)
120+
ssl.close
121+
end
122+
end
98123
end

0 commit comments

Comments
 (0)