Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add patch to aws-sdk-core to fix auth bug #432

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you mentioned this yesterday but will put it here anyway. We probably want to gate this patch for the versions that are affected and when it's fixed so we can eventually remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, wanted to do this via tests, but I guess I can do it in the file as well. Is that what you were thinking?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, we can do this when the gem is released if we remember

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, @blomquisg just #yolomerged before I even got a chance to make a change...

¯\_(ツ)_/¯

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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this makes sense, monkey patch the single method instead of bringing along 2 method changes from the PR.


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