Skip to content

Commit a175a41

Browse files
committed
test/openssl/test_ssl: assume TLS 1.2 support
Current versions of OpenSSL and LibreSSL all support TLS 1.2, so there is no need for checking the availability.
1 parent 7b66eaa commit a175a41

File tree

3 files changed

+26
-55
lines changed

3 files changed

+26
-55
lines changed

test/openssl/test_ssl.rb

Lines changed: 26 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ def test_add_certificate
125125

126126
def test_add_certificate_multiple_certs
127127
pend "EC is not supported" unless defined?(OpenSSL::PKey::EC)
128-
pend "TLS 1.2 is not supported" unless tls12_supported?
129128

130129
ca2_key = Fixtures.pkey("rsa-3")
131130
ca2_exts = [
@@ -554,8 +553,6 @@ def test_sslctx_set_params
554553
end
555554

556555
def test_post_connect_check_with_anon_ciphers
557-
pend "TLS 1.2 is not supported" unless tls12_supported?
558-
559556
ctx_proc = -> ctx {
560557
ctx.ssl_version = :TLSv1_2
561558
ctx.ciphers = "aNULL"
@@ -1355,7 +1352,6 @@ def test_alpn_protocol_selection_cancel
13551352
end
13561353

13571354
def test_npn_protocol_selection_ary
1358-
pend "TLS 1.2 is not supported" unless tls12_supported?
13591355
pend "NPN is not supported" unless \
13601356
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
13611357
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
@@ -1376,7 +1372,6 @@ def test_npn_protocol_selection_ary
13761372
end
13771373

13781374
def test_npn_protocol_selection_enum
1379-
pend "TLS 1.2 is not supported" unless tls12_supported?
13801375
pend "NPN is not supported" unless \
13811376
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
13821377
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
@@ -1401,7 +1396,6 @@ def advertised.each
14011396
end
14021397

14031398
def test_npn_protocol_selection_cancel
1404-
pend "TLS 1.2 is not supported" unless tls12_supported?
14051399
pend "NPN is not supported" unless \
14061400
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14071401
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
@@ -1415,7 +1409,6 @@ def test_npn_protocol_selection_cancel
14151409
end
14161410

14171411
def test_npn_advertised_protocol_too_long
1418-
pend "TLS 1.2 is not supported" unless tls12_supported?
14191412
pend "NPN is not supported" unless \
14201413
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14211414
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
@@ -1429,7 +1422,6 @@ def test_npn_advertised_protocol_too_long
14291422
end
14301423

14311424
def test_npn_selected_protocol_too_long
1432-
pend "TLS 1.2 is not supported" unless tls12_supported?
14331425
pend "NPN is not supported" unless \
14341426
OpenSSL::SSL::SSLContext.method_defined?(:npn_select_cb)
14351427
pend "LibreSSL 2.6 has broken NPN functions" if libressl?(2, 6, 1)
@@ -1470,40 +1462,36 @@ def test_sync_close_without_connect
14701462
end
14711463

14721464
def test_get_ephemeral_key
1473-
if tls12_supported?
1474-
# kRSA
1475-
ctx_proc1 = proc { |ctx|
1476-
ctx.ssl_version = :TLSv1_2
1477-
ctx.ciphers = "kRSA"
1478-
}
1479-
start_server(ctx_proc: ctx_proc1, ignore_listener_error: true) do |port|
1480-
ctx = OpenSSL::SSL::SSLContext.new
1481-
ctx.ssl_version = :TLSv1_2
1482-
ctx.ciphers = "kRSA"
1483-
begin
1484-
server_connect(port, ctx) { |ssl| assert_nil ssl.tmp_key }
1485-
rescue OpenSSL::SSL::SSLError
1486-
# kRSA seems disabled
1487-
raise unless $!.message =~ /no cipher/
1488-
end
1465+
# kRSA
1466+
ctx_proc1 = proc { |ctx|
1467+
ctx.ssl_version = :TLSv1_2
1468+
ctx.ciphers = "kRSA"
1469+
}
1470+
start_server(ctx_proc: ctx_proc1, ignore_listener_error: true) do |port|
1471+
ctx = OpenSSL::SSL::SSLContext.new
1472+
ctx.ssl_version = :TLSv1_2
1473+
ctx.ciphers = "kRSA"
1474+
begin
1475+
server_connect(port, ctx) { |ssl| assert_nil ssl.tmp_key }
1476+
rescue OpenSSL::SSL::SSLError
1477+
# kRSA seems disabled
1478+
raise unless $!.message =~ /no cipher/
14891479
end
14901480
end
14911481

1492-
if defined?(OpenSSL::PKey::DH) && tls12_supported?
1493-
# DHE
1494-
# TODO: How to test this with TLS 1.3?
1495-
ctx_proc2 = proc { |ctx|
1496-
ctx.ssl_version = :TLSv1_2
1497-
ctx.ciphers = "EDH"
1482+
# DHE
1483+
# TODO: How to test this with TLS 1.3?
1484+
ctx_proc2 = proc { |ctx|
1485+
ctx.ssl_version = :TLSv1_2
1486+
ctx.ciphers = "EDH"
1487+
}
1488+
start_server(ctx_proc: ctx_proc2) do |port|
1489+
ctx = OpenSSL::SSL::SSLContext.new
1490+
ctx.ssl_version = :TLSv1_2
1491+
ctx.ciphers = "EDH"
1492+
server_connect(port, ctx) { |ssl|
1493+
assert_instance_of OpenSSL::PKey::DH, ssl.tmp_key
14981494
}
1499-
start_server(ctx_proc: ctx_proc2) do |port|
1500-
ctx = OpenSSL::SSL::SSLContext.new
1501-
ctx.ssl_version = :TLSv1_2
1502-
ctx.ciphers = "EDH"
1503-
server_connect(port, ctx) { |ssl|
1504-
assert_instance_of OpenSSL::PKey::DH, ssl.tmp_key
1505-
}
1506-
end
15071495
end
15081496

15091497
if defined?(OpenSSL::PKey::EC)
@@ -1633,8 +1621,6 @@ def test_tmp_dh
16331621
end
16341622

16351623
def test_ecdh_curves_tls12
1636-
pend "EC is disabled" unless defined?(OpenSSL::PKey::EC)
1637-
16381624
ctx_proc = -> ctx {
16391625
# Enable both ECDHE (~ TLS 1.2) cipher suites and TLS 1.3
16401626
ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION

test/openssl/test_ssl_session.rb

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@
55

66
class OpenSSL::TestSSLSession < OpenSSL::SSLTestCase
77
def test_session
8-
pend "TLS 1.2 is not supported" unless tls12_supported?
9-
108
ctx_proc = proc { |ctx| ctx.ssl_version = :TLSv1_2 }
119
start_server(ctx_proc: ctx_proc) do |port|
1210
server_connect_with_session(port, nil, nil) { |ssl|
@@ -144,8 +142,6 @@ def test_resumption
144142
end
145143

146144
def test_server_session_cache
147-
pend "TLS 1.2 is not supported" unless tls12_supported?
148-
149145
ctx_proc = Proc.new do |ctx|
150146
ctx.ssl_version = :TLSv1_2
151147
ctx.options |= OpenSSL::SSL::OP_NO_TICKET
@@ -224,8 +220,6 @@ def test_server_session_cache
224220
TEST_SESSION_REMOVE_CB = ENV["OSSL_TEST_ALL"] == "1"
225221

226222
def test_ctx_client_session_cb
227-
pend "TLS 1.2 is not supported" unless tls12_supported?
228-
229223
ctx_proc = proc { |ctx| ctx.ssl_version = :TLSv1_2 }
230224
start_server(ctx_proc: ctx_proc) do |port|
231225
called = {}
@@ -257,8 +251,6 @@ def test_ctx_client_session_cb
257251
end
258252

259253
def test_ctx_server_session_cb
260-
pend "TLS 1.2 is not supported" unless tls12_supported?
261-
262254
connections = nil
263255
called = {}
264256
cctx = OpenSSL::SSL::SSLContext.new

test/openssl/utils.rb

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,6 @@ def setup
189189
@server = nil
190190
end
191191

192-
def tls12_supported?
193-
ctx = OpenSSL::SSL::SSLContext.new
194-
ctx.min_version = ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
195-
true
196-
rescue
197-
end
198-
199192
def tls13_supported?
200193
return false unless defined?(OpenSSL::SSL::TLS1_3_VERSION)
201194
ctx = OpenSSL::SSL::SSLContext.new

0 commit comments

Comments
 (0)