| Message: 20564 |
 |
BY: Paul Taylor (ptaylor) DATE: 2007-04-11 20:59 SUBJECT: SSL w/ Basic Authentication via Proxy Hi,
I have the following snippet of code that works with the WinSock proxy client:
uri = URI.parse("https://" + ip_addr +"/")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start do |http|
request = Net::HTTP::Get.new('/Info.live.htm')
request.basic_auth 'username', 'password'
response = http.request(request)
response.value
puts response.body
end
My issue is that I need to do a batch of these (about 15) and each one takes about 15 seconds through WinSock. By using IE configured for the ISA server, that drops to about 2 seconds each. Since speed is important (I'd like to run this a few minutes apart at the most), I sought out a way to use the proxy directly. Ideally, I'd like to do this with the Proxy class, like so:
http = Net::HTTP.Proxy(proxy.host, proxy.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
http.start(ip_addr) do |http|
request = Net::HTTP::Get.new('/Info.live.htm')
request.basic_auth 'username', 'password'
response = http.request(request)
response.value
puts response.body
end
Unfortunately, this fails because use_ssl and verify_mode are undefined methods of the Proxy class. If I comment out those line, I get this:
D:/InstantRails/ruby/lib/ruby/1.8/net/http.rb:2065:in `error!': 502 "Proxy Error ( Connection refused )" (Net::HTTPFatalError)
Which I would expect, since port 80 isn't open on the destination server.
Am I missing something, or can you currently not do SSL with this?
Thanks,
Paul | |