Skip to content

Commit

Permalink
Inhibit SSL certificate checking when in debug mode. Improve log mess…
Browse files Browse the repository at this point in the history
…ages.
  • Loading branch information
John Messenger committed Aug 14, 2018
1 parent 4883b64 commit 18fbbc4
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions maint-uploader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def login(api, username, password)
login_request['user']['password'] = password

begin
# {ssl_verify_mode: OpenSSL::SSL::VERIFY_NONE}
res = api['users/sign_in'].post login_request.to_json, { content_type: :json, accept: :json }
rescue RestClient::ExceptionWithResponse => e
abort "Could not log in: #{e.response.to_s}"
Expand Down Expand Up @@ -248,9 +249,11 @@ def parse_request(url, creds)
if $DEBUG
RestClient.proxy = "http://localhost:8888"
$logger.debug("Using HTTP proxy #{RestClient.proxy}")
maint = RestClient::Resource.new(config['api_uri'], verify_ssl: OpenSSL::SSL::VERIFY_NONE)
else
maint = RestClient::Resource.new(config['api_uri'])
end

maint = RestClient::Resource.new(config['api_uri'])
res = login(maint, config['email'], config['password'])
# Save the session cookie
maint_cookie = {}
Expand Down Expand Up @@ -306,7 +309,7 @@ def parse_request(url, creds)
request = {}
if item
unless opts[:all]
$logger.info 'Stopping at first already-existing item'
$logger.info "Stopping at first already-existing item (#{number})"
throw :done
end
request = find_request(maint, item)
Expand Down Expand Up @@ -338,7 +341,7 @@ def parse_request(url, creds)
num_requests_added_to_existing_items += 1
end
else
$logger.warn "Could not parse request for item #{number}"
$logger.warn "Could not parse request for item #{number} at #{url}"
end
end
end
Expand Down

0 comments on commit 18fbbc4

Please sign in to comment.