From 060184c347822b11dff3db6bef915c04a564c4e4 Mon Sep 17 00:00:00 2001 From: emboss Date: Sun, 6 May 2012 22:26:08 +0000 Subject: * ext/openssl/ossl_ssl.c: support TLSv1.1 & TLSv1.1. Add SSLContext#version to inspect the version that was negotiated for a given connection. * ext/openssl/extconf.rb: detect TLS 1.1 & 1.2 support. * test/openssl/test_ssl.rb: add tests for TLS 1.1 & 1.2 given they are supported by the native OpenSSL being used. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35549 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/openssl/test_ssl.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'test') diff --git a/test/openssl/test_ssl.rb b/test/openssl/test_ssl.rb index 033d1e8be5..3ccb3cda87 100644 --- a/test/openssl/test_ssl.rb +++ b/test/openssl/test_ssl.rb @@ -437,6 +437,35 @@ class OpenSSL::TestSSL < OpenSSL::SSLTestCase ssl.close } end + + def test_tls_v_1_1 + ctx_proc = Proc.new { |ctx| + ctx.ssl_version = :TLSv1_1 + } + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc) { |server, port| + sock = TCPSocket.new("127.0.0.1", port) + ssl = OpenSSL::SSL::SSLSocket.new(sock) + ssl.sync_close = true + ssl.connect + assert_equal("TLSv1.1", ssl.ssl_version) + ssl.close + } + end if OpenSSL::SSL::SSLContext::METHODS.include? :TLSv1_1 + + def test_tls_v_1_2 + ctx_proc = Proc.new { |ctx| + ctx.ssl_version = :TLSv1_2 + } + start_server(PORT, OpenSSL::SSL::VERIFY_NONE, true, :ctx_proc => ctx_proc) { |server, port| + sock = TCPSocket.new("127.0.0.1", port) + ssl = OpenSSL::SSL::SSLSocket.new(sock) + ssl.sync_close = true + ssl.connect + assert_equal("TLSv1.2", ssl.ssl_version) + ssl.close + } + end if OpenSSL::SSL::SSLContext::METHODS.include? :TLSv1_2 + end end -- cgit v1.2.3