Skip to content

Commit

Permalink
Merge pull request #13 from machineepsilon/no-verify-ssl
Browse files Browse the repository at this point in the history
Add verify_ssl option
  • Loading branch information
Chris Le committed Jul 21, 2012
2 parents 87ff358 + b34f8da commit 71f1372
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/gattica/engine.rb
Expand Up @@ -16,6 +16,7 @@ class Engine
# +:profile_id+:: Use this Google Analytics profile_id (default is nil) # +:profile_id+:: Use this Google Analytics profile_id (default is nil)
# +:timeout+:: Set Net:HTTP timeout in seconds (default is 300) # +:timeout+:: Set Net:HTTP timeout in seconds (default is 300)
# +:token+:: Use an authentication token you received before # +:token+:: Use an authentication token you received before
# +:verify_ssl+:: Verify SSL connection (default is true)
def initialize(options={}) def initialize(options={})
@options = Settings::DEFAULT_OPTIONS.merge(options) @options = Settings::DEFAULT_OPTIONS.merge(options)
handle_init_options(@options) handle_init_options(@options)
Expand Down Expand Up @@ -262,6 +263,7 @@ def create_http_connection(server)
port = Settings::USE_SSL ? Settings::SSL_PORT : Settings::NON_SSL_PORT port = Settings::USE_SSL ? Settings::SSL_PORT : Settings::NON_SSL_PORT
@http = Net::HTTP.new(server, port) @http = Net::HTTP.new(server, port)
@http.use_ssl = Settings::USE_SSL @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.set_debug_output $stdout if @options[:debug]
@http.read_timeout = @options[:timeout] if @options[:timeout] @http.read_timeout = @options[:timeout] if @options[:timeout]
end end
Expand Down
5 changes: 4 additions & 1 deletion lib/gattica/settings.rb
Expand Up @@ -4,6 +4,8 @@ module Settings
USE_SSL = true USE_SSL = true
SSL_PORT = 443 SSL_PORT = 443
NON_SSL_PORT = 80 NON_SSL_PORT = 80
NO_VERIFY_SSL_MODE = OpenSSL::SSL::VERIFY_NONE
VERIFY_SSL_MODE = OpenSSL::SSL::VERIFY_PEER


TIMEOUT = 100 TIMEOUT = 100


Expand All @@ -23,7 +25,8 @@ module Settings
:profile_id => nil, :profile_id => nil,
:debug => false, :debug => false,
:headers => {}, :headers => {},
:logger => Logger.new(STDOUT) :logger => Logger.new(STDOUT),
:verify_ssl => true
} }


FILTER_METRIC_OPERATORS = %w{ == != > < >= <= } FILTER_METRIC_OPERATORS = %w{ == != > < >= <= }
Expand Down

0 comments on commit 71f1372

Please sign in to comment.