lib/statsmix.rb in statsmix-0.1.7 vs lib/statsmix.rb in statsmix-0.1.8

- old
+ new

@@ -3,11 +3,11 @@ require 'rubygems' require 'json' class StatsMix BASE_URI = 'https://statsmix.com/api/v2/' - + RootCA = '/etc/ssl/certs' GEM_VERSION = File.exist?('../VERSION') ? File.read('../VERSION') : "" # Track an event # # Required: name of metric @@ -261,13 +261,23 @@ self.setup if @api_key.nil? raise "API key not set. You must set it first with StatsMix.api_key = [your api key]" end + # Resources available: stats, metrics, TODO: profiles @url = URI.parse(BASE_URI + resource) @connection = Net::HTTP.new(@url.host, @url.port) @connection.use_ssl = (@url.scheme == 'https') + + if File.directory? RootCA + @connection.ca_path = RootCA + @connection.verify_mode = OpenSSL::SSL::VERIFY_PEER + @connection.verify_depth = 5 + else + @connection.verify_mode = OpenSSL::SSL::VERIFY_NONE + end + @request = Hash.new @request["User-Agent"] = @user_agent @params = Hash.new @params[:api_key] = @api_key end \ No newline at end of file