ruby: function created

This commit is contained in:
Olga Larinova
2022-03-28 09:31:01 +03:00
parent 405be2847b
commit 089fc8bfa0
5 changed files with 14 additions and 32 deletions

View File

@ -118,12 +118,7 @@ class HomeController < ApplicationController
uri = URI.parse(new_file_uri) # create the request url
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
if new_file_uri.start_with?('https')
http.use_ssl = true
if Rails.configuration.verify_peer_off == TRUE
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
end
end
DocumentHelper.verify_ssl(new_file_uri, http)
req = Net::HTTP::Get.new(uri.request_uri) # create the get requets
res = http.request(req)
@ -326,12 +321,8 @@ class HomeController < ApplicationController
uri = URI.parse(file_url) # create the request url
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
if file_url.start_with?('https')
http.use_ssl = true
if Rails.configuration.verify_peer_off == TRUE
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
end
end
DocumentHelper.verify_ssl(file_url, http)
req = Net::HTTP::Get.new(uri.request_uri) # create the get requets
res = http.request(req)
data = res.body

View File

@ -340,7 +340,13 @@ class DocumentHelper
return result
end
end
# enable ignore certificate
def verify_ssl(file_uri, http)
if file_uri.start_with?('https') && Rails.configuration.verify_peer_off.eql?('true')
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
end
end
end
end

View File

@ -51,12 +51,7 @@ class ServiceConverter
uri = URI.parse(@@document_converter_url) # create the request url
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
if @@document_converter_url.start_with?('https')
http.use_ssl = true
if Rails.configuration.verify_peer_off == TRUE
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
end
end
DocumentHelper.verify_ssl(@@document_converter_url, http)
http.read_timeout = @@convert_timeout
req = Net::HTTP::Post.new(uri.request_uri) # create the post request

View File

@ -225,12 +225,7 @@ class TrackHelper
uri = URI.parse(document_command_url) # parse the document command url
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
if document_command_url.start_with?('https') # check if the documnent command url starts with https
http.use_ssl = true
if Rails.configuration.verify_peer_off == TRUE
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
end
end
DocumentHelper.verify_ssl(document_command_url, http)
req = Net::HTTP::Post.new(uri.request_uri) # create the post request
req.add_field("Content-Type", "application/json") # set headers
@ -257,12 +252,7 @@ class TrackHelper
uri = URI.parse(uristr) # parse the url string
http = Net::HTTP.new(uri.host, uri.port) # create a connection to the http server
if uristr.start_with?('https') # check if the documnent command url starts with https
http.use_ssl = true
if Rails.configuration.verify_peer_off == TRUE
http.verify_mode = OpenSSL::SSL::VERIFY_NONE # set the flags for the server certificate verification at the beginning of SSL session
end
end
DocumentHelper.verify_ssl(uristr, http)
req = Net::HTTP::Get.new(uri)
res = http.request(req) # get the response

View File

@ -48,6 +48,6 @@ module OnlineEditorsExampleRuby
Rails.configuration.jwtSecret = ""
Rails.configuration.header="Authorization"
Rails.configuration.verify_peer_off = TRUE
Rails.configuration.verify_peer_off = "true"
end
end