lib/growthforecast/client.rb in growthforecast-client-0.82.4 vs lib/growthforecast/client.rb in growthforecast-client-0.82.5

- old
+ new

@@ -1,7 +1,8 @@ # -*- encoding: utf-8 -*- require 'net/http' +require 'net/https' require 'uri' require 'json' require 'cgi' module GrowthForecast @@ -23,26 +24,32 @@ def initialize(base_uri = 'http://127.0.0.1:5125', opts = {}) @base_uri = base_uri opts = stringify_keys(opts) URI.parse(base_uri).tap {|uri| - @host = uri.host - @port = uri.port - @use_ssl = uri.scheme == 'https' + @host = uri.host + @port = uri.port + @use_ssl = uri.scheme == 'https' } @debug_dev = opts['debug_dev'] # IO object such as STDOUT @open_timeout = opts['open_timeout'] # 60 @read_timeout = opts['read_timeout'] # 60 - @verify_ssl = opts['verify_ssl'] @keepalive = opts['keepalive'] + @verify_ssl = opts['verify_ssl'] + @ca_file = opts['ca_file'] end def http_connection Net::HTTP.new(@host, @port).tap {|http| http.use_ssl = @use_ssl http.open_timeout = @open_timeout if @open_timeout http.read_timeout = @read_timeout if @read_timeout - http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify_ssl + if @verify_ssl + http.verify_mode = OpenSSL::SSL::VERIFY_PEER + http.ca_file = @ca_file if @ca_file + else + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + end http.set_debug_output(@debug_dev) if @debug_dev } end def get_request(path, extheader = {})