chetan-clickapps / activemessaging

Automatically exported from code.google.com/p/activemessaging
0 stars 0 forks source link

Amazon SQS adapter doesn't honor SSL #43

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Use this configuration in broker.yaml:
    adapter: asqs
    access_key_id: XXXX
    secret_access_key: XXXX
    protocol: https
    port: 443

2. Fire off a message to the queue. You will see this:

Timed out trying to send the message #<OpenStruct body="--- \ntype:
forgot_username_password\nuser: 1\n", headers={:persistent=>true}> to
destination email_queue via broker default

Timeout::Error (execution expired):
    /usr/local/lib/ruby/1.8/timeout.rb:60:in `make_request'

/vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb:136:in
`list_queues'

/vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb:263:in
`queues'

/vendor/plugins/activemessaging/lib/activemessaging/adapters/asqs.rb:52:in
`initialize'
    /vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:112:in `new'
    /vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:112:in
`connection'
    /vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:300:in
`publish'
    /vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:149:in
`execute_filter_chain'
    /vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:299:in
`publish'
    /vendor/plugins/activemessaging/lib/activemessaging/gateway.rb:298:in
`publish'

/vendor/plugins/activemessaging/lib/activemessaging/message_sender.rb:21:in
`publish'
    /app/controllers/users_controller.rb:596:in `forgotemail'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1253:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:1253:in
`perform_action_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:617:in
`call_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:610:in
`perform_action_without_benchmark'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
    /usr/local/lib/ruby/1.8/benchmark.rb:293:in `measure'
    /vendor/rails/actionpack/lib/action_controller/benchmarking.rb:68:in
`perform_action_without_rescue'
    /vendor/rails/actionpack/lib/action_controller/rescue.rb:136:in
`perform_action_without_caching'

/vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:13:in
`perform_action'

/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/query_
cache.rb:34:in
`cache'
    /vendor/rails/activerecord/lib/active_record/query_cache.rb:8:in `cache'

/vendor/rails/actionpack/lib/action_controller/caching/sql_cache.rb:12:in
`perform_action'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in `send'
    /vendor/rails/actionpack/lib/action_controller/base.rb:524:in
`process_without_filters'
    /vendor/rails/actionpack/lib/action_controller/filters.rb:606:in
`process_without_session_management_support'

/vendor/rails/actionpack/lib/action_controller/session_management.rb:134:in
`process'
    /vendor/rails/actionpack/lib/action_controller/base.rb:392:in `process'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:183:in
`handle_request'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:110:in
`dispatch_unlocked'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:123:in
`dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in
`synchronize'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:122:in
`dispatch'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:132:in
`dispatch_cgi'
    /vendor/rails/actionpack/lib/action_controller/dispatcher.rb:39:in
`dispatch'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:76:i
n
`process'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:i
n
`synchronize'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/rails.rb:74:i
n
`process'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:159:in 
`process_client'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in 
`each'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:158:in 
`process_client'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in 
`run'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in 
`initialize'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in 
`new'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:285:in 
`run'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in 
`initialize'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in 
`new'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel.rb:268:in 
`run'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.
rb:282:in
`run'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.
rb:281:in
`each'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/configurator.
rb:281:in
`run'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:128:in `run'

/usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/../lib/mongrel/command.rb:21
2:in
`run'
    /usr/local/lib/ruby/gems/1.8/gems/mongrel-1.1.5/bin/mongrel_rails:281
    /usr/local/bin/mongrel_rails:19:in `load'
    /usr/local/bin/mongrel_rails:19

What version of the product are you using? On what operating system?

Revision 151 on OS X 10.5.6

Please provide any additional information below.

It looks like activemessaging/adapters/asqs.rb needs the following changes:

As reported here...

http://groups.google.com/group/activemessaging-discuss/browse_thread/thread/7a7c
46ed4ef401c0?fwc=1&pli=1

...needs the following changes:

1. require 'net/https'

2. Change this method to something similiar:
        # I wrap this so I can move to a different client, or easily mock
for testing
        def http_request h, p, r
          # ORIGINAL
          #return Net::HTTP.start(h, p){ |http| http.request(r) }
          # patch to get SSL working
          http = Net::HTTP.new(h, p)
          http.use_ssl = true if "https" == @protocol
          return http.request(r) 
        end

3. Change this method to allow for https:// urls:

      class Queue

        def self.from_url url
          return Queue.new($2,$1) if (url =~
/^http:\/\/(.+)\/([-a-zA-Z0-9_]+)$/)
          raise "Bad Queue URL: #{url}"
        end

4. Other? (Still trying to get it working by manually patching the file.
Will report more when I get it working.)

Original issue reported on code.google.com by bplo...@gmail.com on 20 Apr 2009 at 4:50

GoogleCodeExporter commented 8 years ago
Doug Bryant was kind enough to send me his copy of this file patched to get SSL
working. Attached is the diff (thanks again Doug!)

Original comment by bplo...@gmail.com on 24 Apr 2009 at 2:22

Attachments:

GoogleCodeExporter commented 8 years ago
And to get rid of the annoying "warning: peer certificate won't be verified 
in this
SSL session" messages that get spewed twice per polling loop execution, add 
this:

# I wrap this so I can move to a different client, or easily mock for testing
def http_request h, p, r
  #return Net::HTTP.start(h, p){ |http| http.request(r) }
  http = Net::HTTP.new(h, p)
  http.use_ssl = true if "https" == @protocol
  # Don't carp about SSL cert verification
  http.verify_mode = OpenSSL::SSL::VERIFY_NONE
  return http.request(r)
end

Original comment by bplo...@gmail.com on 24 Apr 2009 at 2:54