Skip to content

Commit 2cd01d4

Browse files
committed
test/openssl/test_ssl: assume ECC support
Disabling ECC support of OpenSSL is impractical nowadays. We still try to have the C extension compile on no-ec builds (as well as no-dh or no-engine, etc.) as long as we can, but keeping test cases for such an extreme scenario is not worth the effort.
1 parent a175a41 commit 2cd01d4

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

test/openssl/test_pair.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ def ssl_pair
2323
sctx = OpenSSL::SSL::SSLContext.new
2424
sctx.cert = @svr_cert
2525
sctx.key = @svr_key
26-
sctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
2726
sctx.options |= OpenSSL::SSL::OP_NO_COMPRESSION
2827
ssls = OpenSSL::SSL::SSLServer.new(tcps, sctx)
2928
ns = ssls.accept
@@ -383,7 +382,6 @@ def test_connect_accept_nonblock_no_exception
383382
ctx2 = OpenSSL::SSL::SSLContext.new
384383
ctx2.cert = @svr_cert
385384
ctx2.key = @svr_key
386-
ctx2.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
387385

388386
sock1, sock2 = tcp_pair
389387

@@ -431,7 +429,6 @@ def test_connect_accept_nonblock
431429
ctx = OpenSSL::SSL::SSLContext.new
432430
ctx.cert = @svr_cert
433431
ctx.key = @svr_key
434-
ctx.tmp_dh_callback = proc { OpenSSL::TestUtils::Fixtures.pkey("dh-1") }
435432

436433
sock1, sock2 = tcp_pair
437434

test/openssl/test_pkey_ec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# frozen_string_literal: true
22
require_relative 'utils'
33

4-
if defined?(OpenSSL) && defined?(OpenSSL::PKey::EC)
4+
if defined?(OpenSSL)
55

66
class OpenSSL::TestEC < OpenSSL::PKeyTestCase
77
def test_ec_key

test/openssl/test_ssl.rb

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,6 @@ def test_add_certificate
124124
end
125125

126126
def test_add_certificate_multiple_certs
127-
pend "EC is not supported" unless defined?(OpenSSL::PKey::EC)
128-
129127
ca2_key = Fixtures.pkey("rsa-3")
130128
ca2_exts = [
131129
["basicConstraints", "CA:TRUE", true],
@@ -556,6 +554,7 @@ def test_post_connect_check_with_anon_ciphers
556554
ctx_proc = -> ctx {
557555
ctx.ssl_version = :TLSv1_2
558556
ctx.ciphers = "aNULL"
557+
ctx.tmp_dh = Fixtures.pkey("dh-1")
559558
ctx.security_level = 0
560559
}
561560

@@ -830,7 +829,6 @@ def socketpair
830829

831830
def test_tlsext_hostname
832831
fooctx = OpenSSL::SSL::SSLContext.new
833-
fooctx.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
834832
fooctx.cert = @cli_cert
835833
fooctx.key = @cli_key
836834

@@ -882,7 +880,6 @@ def test_servername_cb_raises_an_exception_on_unknown_objects
882880
ctx2 = OpenSSL::SSL::SSLContext.new
883881
ctx2.cert = @svr_cert
884882
ctx2.key = @svr_key
885-
ctx2.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
886883
ctx2.servername_cb = lambda { |args| Object.new }
887884

888885
sock1, sock2 = socketpair
@@ -1329,7 +1326,6 @@ def test_alpn_protocol_selection_cancel
13291326
ctx1 = OpenSSL::SSL::SSLContext.new
13301327
ctx1.cert = @svr_cert
13311328
ctx1.key = @svr_key
1332-
ctx1.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
13331329
ctx1.alpn_select_cb = -> (protocols) { nil }
13341330
ssl1 = OpenSSL::SSL::SSLSocket.new(sock1, ctx1)
13351331

@@ -1484,6 +1480,7 @@ def test_get_ephemeral_key
14841480
ctx_proc2 = proc { |ctx|
14851481
ctx.ssl_version = :TLSv1_2
14861482
ctx.ciphers = "EDH"
1483+
ctx.tmp_dh = Fixtures.pkey("dh-1")
14871484
}
14881485
start_server(ctx_proc: ctx_proc2) do |port|
14891486
ctx = OpenSSL::SSL::SSLContext.new
@@ -1494,20 +1491,18 @@ def test_get_ephemeral_key
14941491
}
14951492
end
14961493

1497-
if defined?(OpenSSL::PKey::EC)
1498-
# ECDHE
1499-
ctx_proc3 = proc { |ctx|
1500-
ctx.ciphers = "DEFAULT:!kRSA:!kEDH"
1501-
ctx.ecdh_curves = "P-256"
1494+
# ECDHE
1495+
ctx_proc3 = proc { |ctx|
1496+
ctx.ciphers = "DEFAULT:!kRSA:!kEDH"
1497+
ctx.ecdh_curves = "P-256"
1498+
}
1499+
start_server(ctx_proc: ctx_proc3) do |port|
1500+
ctx = OpenSSL::SSL::SSLContext.new
1501+
ctx.ciphers = "DEFAULT:!kRSA:!kEDH"
1502+
server_connect(port, ctx) { |ssl|
1503+
assert_instance_of OpenSSL::PKey::EC, ssl.tmp_key
1504+
ssl.puts "abc"; assert_equal "abc\n", ssl.gets
15021505
}
1503-
start_server(ctx_proc: ctx_proc3) do |port|
1504-
ctx = OpenSSL::SSL::SSLContext.new
1505-
ctx.ciphers = "DEFAULT:!kRSA:!kEDH"
1506-
server_connect(port, ctx) { |ssl|
1507-
assert_instance_of OpenSSL::PKey::EC, ssl.tmp_key
1508-
ssl.puts "abc"; assert_equal "abc\n", ssl.gets
1509-
}
1510-
end
15111506
end
15121507
end
15131508

@@ -1656,7 +1651,6 @@ def test_ecdh_curves_tls12
16561651
end
16571652

16581653
def test_ecdh_curves_tls13
1659-
pend "EC is disabled" unless defined?(OpenSSL::PKey::EC)
16601654
pend "TLS 1.3 not supported" unless tls13_supported?
16611655

16621656
ctx_proc = -> ctx {

test/openssl/utils.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ def start_server(verify_mode: OpenSSL::SSL::VERIFY_NONE, start_immediately: true
215215
ctx.cert_store = store
216216
ctx.cert = @svr_cert
217217
ctx.key = @svr_key
218-
ctx.tmp_dh_callback = proc { Fixtures.pkey("dh-1") }
219218
ctx.verify_mode = verify_mode
220219
ctx_proc.call(ctx) if ctx_proc
221220

0 commit comments

Comments
 (0)