Skip to content

Commit

Permalink
Merge pull request #432 from NickLaMuro/monkey-patch-aws-sdk-core-for…
Browse files Browse the repository at this point in the history
…-proxy-auth-fix

Add patch to aws-sdk-core to fix auth bug
(cherry picked from commit 2b2c87f)

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1568467
  • Loading branch information
blomquisg authored and simaishi committed Apr 17, 2018
1 parent 6101717 commit 6b45662
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/models/authenticator/amazon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def aws_connect(access_key_id, secret_access_key, service = :IAM, proxy_uri = ni
proxy_uri ||= VMDB::Util.http_proxy_uri

require 'aws-sdk'
require 'patches/aws-sdk-core/seahorse_client_net_http_pool_patch'
Aws.const_get(service)::Resource.new(
:access_key_id => access_key_id,
:secret_access_key => secret_access_key,
Expand Down
2 changes: 2 additions & 0 deletions app/models/manageiq/providers/amazon/manager_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module ClassMethods

def raw_connect(access_key_id, secret_access_key, service, region, proxy_uri = nil, validate = false)
require 'aws-sdk'
require 'patches/aws-sdk-core/seahorse_client_net_http_pool_patch'

connection = Aws.const_get(service)::Resource.new(
:access_key_id => access_key_id,
Expand Down Expand Up @@ -84,6 +85,7 @@ def connection_rescue_block

def translate_exception(err)
require 'aws-sdk'
require 'patches/aws-sdk-core/seahorse_client_net_http_pool_patch'
case err
when Aws::EC2::Errors::SignatureDoesNotMatch
MiqException::MiqHostError.new "SignatureMismatch - check your AWS Secret Access Key and signing method"
Expand Down
44 changes: 44 additions & 0 deletions lib/patches/aws-sdk-core/seahorse_client_net_http_pool_patch.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Autoload the connection pool
Seahorse::Client::NetHttp::ConnectionPool

module Seahorse
module Client
module NetHttp
class ConnectionPool
def start_session endpoint

endpoint = URI.parse(endpoint)

args = []
args << endpoint.host
args << endpoint.port
args << http_proxy.host
args << http_proxy.port
args << (http_proxy.user && CGI::unescape(http_proxy.user))
args << (http_proxy.password && CGI::unescape(http_proxy.password))

http = ExtendedSession.new(Net::HTTP.new(*args.compact))
http.set_debug_output(logger) if http_wire_trace?
http.open_timeout = http_open_timeout

if endpoint.scheme == 'https'
http.use_ssl = true
if ssl_verify_peer?
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
http.ca_file = ssl_ca_bundle if ssl_ca_bundle
http.ca_path = ssl_ca_directory if ssl_ca_directory
http.cert_store = ssl_ca_store if ssl_ca_store
else
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
else
http.use_ssl = false
end

http.start
http
end
end
end
end
end

0 comments on commit 6b45662

Please sign in to comment.