Skip to content
This repository

Add verify_ssl option #13

Merged
merged 1 commit into from almost 2 years ago

2 participants

Alex Boster Chris Le
Alex Boster

I have added an option to those accepted by Gattica#new, :verify_ssl, that sets the SSL verify mode on the Net::HTTP connection.

Chris Le chrisle merged commit 71f1372 into from
Chris Le chrisle closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Jul 18, 2012
Alex Boster tilthouse Add verify_ssl option b34f8da
This page is out of date. Refresh to see the latest.

Showing 2 changed files with 6 additions and 1 deletion. Show diff stats Hide diff stats

  1. +2 0  lib/gattica/engine.rb
  2. +4 1 lib/gattica/settings.rb
2  lib/gattica/engine.rb
@@ -16,6 +16,7 @@ class Engine
16 16 # +:profile_id+:: Use this Google Analytics profile_id (default is nil)
17 17 # +:timeout+:: Set Net:HTTP timeout in seconds (default is 300)
18 18 # +:token+:: Use an authentication token you received before
  19 + # +:verify_ssl+:: Verify SSL connection (default is true)
19 20 def initialize(options={})
20 21 @options = Settings::DEFAULT_OPTIONS.merge(options)
21 22 handle_init_options(@options)
@@ -262,6 +263,7 @@ def create_http_connection(server)
262 263 port = Settings::USE_SSL ? Settings::SSL_PORT : Settings::NON_SSL_PORT
263 264 @http = Net::HTTP.new(server, port)
264 265 @http.use_ssl = Settings::USE_SSL
  266 + @http.verify_mode = @options[:verify_ssl] ? Settings::VERIFY_SSL_MODE : Settings::NO_VERIFY_SSL_MODE
265 267 @http.set_debug_output $stdout if @options[:debug]
266 268 @http.read_timeout = @options[:timeout] if @options[:timeout]
267 269 end
5 lib/gattica/settings.rb
@@ -4,6 +4,8 @@ module Settings
4 4 USE_SSL = true
5 5 SSL_PORT = 443
6 6 NON_SSL_PORT = 80
  7 + NO_VERIFY_SSL_MODE = OpenSSL::SSL::VERIFY_NONE
  8 + VERIFY_SSL_MODE = OpenSSL::SSL::VERIFY_PEER
7 9
8 10 TIMEOUT = 100
9 11
@@ -23,7 +25,8 @@ module Settings
23 25 :profile_id => nil,
24 26 :debug => false,
25 27 :headers => {},
26   - :logger => Logger.new(STDOUT)
  28 + :logger => Logger.new(STDOUT),
  29 + :verify_ssl => true
27 30 }
28 31
29 32 FILTER_METRIC_OPERATORS = %w{ == != > < >= <= }

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.