Permalink
Browse files

Merge pull request #13 from machineepsilon/no-verify-ssl

Add verify_ssl option
  • Loading branch information...
2 parents 87ff358 + b34f8da commit 71f13725e2f5a74d277a3ee6ff956dd69a71d019 Chris Le committed Jul 21, 2012
Showing with 6 additions and 1 deletion.
  1. +2 −0 lib/gattica/engine.rb
  2. +4 −1 lib/gattica/settings.rb
View
@@ -16,6 +16,7 @@ class Engine
# +:profile_id+:: Use this Google Analytics profile_id (default is nil)
# +:timeout+:: Set Net:HTTP timeout in seconds (default is 300)
# +:token+:: Use an authentication token you received before
+ # +:verify_ssl+:: Verify SSL connection (default is true)
def initialize(options={})
@options = Settings::DEFAULT_OPTIONS.merge(options)
handle_init_options(@options)
@@ -262,6 +263,7 @@ def create_http_connection(server)
port = Settings::USE_SSL ? Settings::SSL_PORT : Settings::NON_SSL_PORT
@http = Net::HTTP.new(server, port)
@http.use_ssl = Settings::USE_SSL
+ @http.verify_mode = @options[:verify_ssl] ? Settings::VERIFY_SSL_MODE : Settings::NO_VERIFY_SSL_MODE
@http.set_debug_output $stdout if @options[:debug]
@http.read_timeout = @options[:timeout] if @options[:timeout]
end
View
@@ -4,6 +4,8 @@ module Settings
USE_SSL = true
SSL_PORT = 443
NON_SSL_PORT = 80
+ NO_VERIFY_SSL_MODE = OpenSSL::SSL::VERIFY_NONE
+ VERIFY_SSL_MODE = OpenSSL::SSL::VERIFY_PEER
TIMEOUT = 100
@@ -23,7 +25,8 @@ module Settings
:profile_id => nil,
:debug => false,
:headers => {},
- :logger => Logger.new(STDOUT)
+ :logger => Logger.new(STDOUT),
+ :verify_ssl => true
}
FILTER_METRIC_OPERATORS = %w{ == != > < >= <= }

0 comments on commit 71f1372

Please sign in to comment.