Skip to content

Commit

Permalink
Merge 3fedfb6 into 7bc8ed8
Browse files Browse the repository at this point in the history
  • Loading branch information
webhoernchen authored Jan 11, 2018
2 parents 7bc8ed8 + 3fedfb6 commit dec720d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ rvm:
- 2.1.8
- 2.2.4
- 2.3.0
- 2.5.0
- jruby
env:
global:
Expand Down
10 changes: 9 additions & 1 deletion lib/httpi/auth/ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,15 @@ class SSL

VERIFY_MODES = [:none, :peer, :fail_if_no_peer_cert, :client_once]
CERT_TYPES = [:pem, :der]
SSL_VERSIONS = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match(/server|client/) }.sort.reverse

# Fix for
# httpi/auth/ssl.rb:13: warning: constant OpenSSL::SSL::SSLContext::METHODS is deprecated
ssl_context = OpenSSL::SSL::SSLContext
SSL_VERSIONS = if ssl_context.const_defined? :METHODS_MAP
ssl_context.const_get(:METHODS_MAP).keys
else
ssl_context::METHODS.reject { |method| method.match(/server|client/) }
end.sort.reverse

# Returns whether SSL configuration is present.
def present?
Expand Down
10 changes: 8 additions & 2 deletions spec/httpi/adapter/curb_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,14 @@
end

it 'to 2 when ssl_version is specified as SSLv2/SSLv23' do
version = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match(/server|client/) }
version = version.select { |method| method.to_s.match(/SSLv2|SSLv23/) }.first
ssl_context = OpenSSL::SSL::SSLContext
versions = if ssl_context.const_defined? :METHODS_MAP
ssl_context.const_get(:METHODS_MAP).keys
else
ssl_context::METHODS.reject { |method| method.match(/server|client/) }
end

version = versions.select { |method| method.to_s.match(/SSLv2|SSLv23/) }.first
request.auth.ssl.ssl_version = version
curb.expects(:ssl_version=).with(2)

Expand Down
7 changes: 6 additions & 1 deletion spec/httpi/auth/ssl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@

describe HTTPI::Auth::SSL do
before(:all) do
@ssl_versions = OpenSSL::SSL::SSLContext::METHODS.reject { |method| method.match(/server|client/) }.sort.reverse
ssl_context = OpenSSL::SSL::SSLContext
@ssl_versions = if ssl_context.const_defined? :METHODS_MAP
ssl_context.const_get(:METHODS_MAP).keys
else
ssl_context::METHODS.reject { |method| method.match(/server|client/) }
end.sort.reverse
end

describe "VERIFY_MODES" do
Expand Down

0 comments on commit dec720d

Please sign in to comment.