Skip to content

Commit

Permalink
Refactoring to incorporate review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mj-vivavis committed Aug 7, 2024
1 parent 206e431 commit 778d232
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
3 changes: 0 additions & 3 deletions ext/openssl/ossl_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1120,9 +1120,6 @@ ossl_sslctx_set_sigalgs(VALUE self, VALUE v)
{
SSL_CTX *ctx;

if (NIL_P(v))
return v;

rb_check_frozen(self);
GetSSLCTX(self, ctx);

Expand Down
38 changes: 19 additions & 19 deletions test/openssl/test_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1736,25 +1736,6 @@ def test_ciphersuites_method_bogus_csuite
) { ssl_ctx.ciphersuites = 'BOGUS' }
end

def test_ciphers_method_tls_connection
csuite = ['ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1.2', 256, 256]
inputs = [csuite[0], [csuite[0]], [csuite]]

start_server do |port|
inputs.each do |input|
cli_ctx = OpenSSL::SSL::SSLContext.new
cli_ctx.min_version = cli_ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
cli_ctx.ciphers = input

server_connect(port, cli_ctx) do |ssl|
assert_equal('TLSv1.2', ssl.ssl_version)
assert_equal(csuite[0], ssl.cipher[0])
ssl.puts('abc'); assert_equal("abc\n", ssl.gets)
end
end
end
end

def test_sigalgs_method_nil_argument
ssl_ctx = OpenSSL::SSL::SSLContext.new
pend 'sigalgs= method is missing' unless ssl_ctx.respond_to?(:sigalgs=)
Expand Down Expand Up @@ -1785,6 +1766,25 @@ def test_sigalgs_method_bogus_sigalgs
assert_raise(OpenSSL::SSL::SSLError) { ssl_ctx.sigalgs = 'BOGUS' }
end

def test_ciphers_method_tls_connection
csuite = ['ECDHE-RSA-AES256-GCM-SHA384', 'TLSv1.2', 256, 256]
inputs = [csuite[0], [csuite[0]], [csuite]]

start_server do |port|
inputs.each do |input|
cli_ctx = OpenSSL::SSL::SSLContext.new
cli_ctx.min_version = cli_ctx.max_version = OpenSSL::SSL::TLS1_2_VERSION
cli_ctx.ciphers = input

server_connect(port, cli_ctx) do |ssl|
assert_equal('TLSv1.2', ssl.ssl_version)
assert_equal(csuite[0], ssl.cipher[0])
ssl.puts('abc'); assert_equal("abc\n", ssl.gets)
end
end
end
end

def test_ciphers_method_nil_argument
ssl_ctx = OpenSSL::SSL::SSLContext.new
assert_nothing_raised { ssl_ctx.ciphers = nil }
Expand Down

0 comments on commit 778d232

Please sign in to comment.