Skip to content

Commit

Permalink
variable name refactoring
Browse files Browse the repository at this point in the history
To make the purpose clear
  • Loading branch information
Hiroshi Nakamura committed Dec 9, 2016
1 parent d0bdad4 commit fc5a9dd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 6 additions & 6 deletions lib/httpclient/ssl_socket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def self.create_socket(session)
end
end

def initialize(socket, context, debug_dev = nil)
def initialize(socket, config, debug_dev = nil)
unless SSLEnabled
raise ConfigurationError.new('Ruby/OpenSSL module is required')
end
@socket = socket
@context = context
@config = config
@ssl_socket = create_openssl_socket(@socket)
@debug_dev = debug_dev
end
Expand Down Expand Up @@ -109,7 +109,7 @@ def sync=(sync)
private

def post_connection_check(hostname)
verify_mode = @context.verify_mode || OpenSSL::SSL::VERIFY_NONE
verify_mode = @config.verify_mode || OpenSSL::SSL::VERIFY_NONE
if verify_mode == OpenSSL::SSL::VERIFY_NONE
return
elsif @ssl_socket.peer_cert.nil? and
Expand All @@ -119,7 +119,7 @@ def post_connection_check(hostname)
if @ssl_socket.respond_to?(:post_connection_check) and RUBY_VERSION > "1.8.4"
@ssl_socket.post_connection_check(hostname)
else
@context.post_connection_check(@ssl_socket.peer_cert, hostname)
@config.post_connection_check(@ssl_socket.peer_cert, hostname)
end
end

Expand All @@ -131,11 +131,11 @@ def create_openssl_socket(socket)
ssl_socket = nil
if OpenSSL::SSL.const_defined?("SSLContext")
ctx = OpenSSL::SSL::SSLContext.new
@context.set_context(ctx)
@config.set_context(ctx)
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket, ctx)
else
ssl_socket = OpenSSL::SSL::SSLSocket.new(socket)
@context.set_context(ssl_socket)
@config.set_context(ssl_socket)
end
ssl_socket
end
Expand Down
4 changes: 3 additions & 1 deletion test/test_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,9 @@ def test_allow_tlsv1
end

def test_use_higher_TLS
omit('TODO: it does not pass with Java 7 or old openssl ')
if defined?(HTTPClient::JRubySSLSocket)
omit('TODO: it does not pass with Java 7 or old openssl ')
end
teardown_server
setup_server_with_ssl_version('TLSv1_2')
assert_nothing_raised do
Expand Down

0 comments on commit fc5a9dd

Please sign in to comment.