From d860d166df8f553d320119de6f19b0a84a2a7ddc Mon Sep 17 00:00:00 2001 From: Leonardo Crauss Daronco Date: Tue, 16 Aug 2016 13:09:19 -0300 Subject: [PATCH] Make mconf-decrypter work with HTTPS and redirects It now works with HTTPS URLs and will follow one redirect. The redirect is useful for when the server being requested redirects HTTP to HTTPS. --- .../mconf_decrypter/scripts/mconf-decrypter.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/record-and-playback/mconf_decrypter/scripts/mconf-decrypter.rb b/record-and-playback/mconf_decrypter/scripts/mconf-decrypter.rb index 3e22ce9d7d..1dee13ab47 100755 --- a/record-and-playback/mconf_decrypter/scripts/mconf-decrypter.rb +++ b/record-and-playback/mconf_decrypter/scripts/mconf-decrypter.rb @@ -40,11 +40,25 @@ $recording_dir = bbb_props['recording_dir'] $raw_dir = "#{$recording_dir}/raw" $archived_dir = "#{$recording_dir}/status/archived" +def getRequest(url) + BigBlueButton.logger.info("Fetching #{url}") + url_parsed = URI.parse(url) + http = Net::HTTP.new(url_parsed.host, url_parsed.port) + http.use_ssl = (url_parsed.scheme.downcase == "https") + http.get(url_parsed.request_uri) +end + def fetchRecordings(url) - #BigBlueButton.logger.debug("Fetching #{url}") doc = nil begin - doc = Nokogiri::XML(Net::HTTP.get_response(URI.parse(url)).body) + response = getRequest(url) + # follow redirects once only + if response.kind_of?(Net::HTTPRedirection) + BigBlueButton.logger.info("Received a redirect, will make a new request") + response = getRequest(response['location']) + end + + doc = Nokogiri::XML(response.body) returncode = doc.xpath("//returncode") if returncode.empty? or returncode.text != "SUCCESS" BigBlueButton.logger.error "getRecordings didn't return success:\n#{doc.to_xml(:indent => 2)}"