lib/scout/command/sign.rb in scout-5.3.4 vs lib/scout/command/sign.rb in scout-5.3.5
- old
+ new
@@ -9,11 +9,11 @@
CA_FILE = File.join( File.dirname(__FILE__),
*%w[.. .. .. data cacert.pem] )
VERIFY_MODE = OpenSSL::SSL::VERIFY_PEER | OpenSSL::SSL::VERIFY_FAIL_IF_NO_PEER_CERT
def run
- url, *provided_options = @args
+ url = @args.first
# read the plugin_code from the file specified
if url.nil? or url == ''
puts "Please specify the path to the plugin (scout sign /path/to/plugin.rb)"
return
end
@@ -33,10 +33,16 @@
code_signature = private_key.sign( OpenSSL::Digest::SHA1.new, code)
sig=Base64.encode64(code_signature)
puts "Posting Signature..."
uri = URI.parse(url)
- http = Net::HTTP.new(uri.host, uri.port)
+
+ # take care of http/https proxy, if specified in command line options
+ # Given a blank string, the proxy_uri URI instance's host/port/user/pass will be nil
+ # Net::HTTP::Proxy returns a regular Net::HTTP class if the first argument (host) is nil
+ proxy_uri = URI.parse(uri.is_a?(URI::HTTPS) ? @https_proxy : @http_proxy)
+ http=Net::HTTP::Proxy(proxy_uri.host,proxy_uri.port,proxy_uri.user,proxy_uri.port).new(uri.host, uri.port)
+
if uri.is_a?(URI::HTTPS)
http.use_ssl = true
http.ca_file = CA_FILE
http.verify_mode = VERIFY_MODE
end