fix https cert error

This commit is contained in:
邱博亞 2021-01-11 20:19:03 +08:00
parent bd95e242f9
commit 19807613c2
1 changed files with 8 additions and 2 deletions

View File

@ -7,14 +7,20 @@ namespace :feeds_module do
feed_directory = File.join(main_directory.to_s, site_feed.id.to_s)
FileUtils.mkdir_p(feed_directory) if !File.exists?(feed_directory)
uri = URI(site_feed.feed_url)
res_net = Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 60,read_timeout: 60) do |http|
res_net = Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
open_timeout: 60,read_timeout: 60,
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
req = Net::HTTP::Get.new(uri)
http.request(req)
end
if (res_net.code == '301' rescue true)
begin
uri = URI(res_net['location'])
res_net = Net::HTTP.start(uri.host, uri.port,:use_ssl => uri.scheme == 'https',open_timeout: 60,read_timeout: 60) do |http|
res_net = Net::HTTP.start(uri.host, uri.port,
:use_ssl => uri.scheme == 'https',
open_timeout: 60,read_timeout: 60,
verify_mode: OpenSSL::SSL::VERIFY_NONE) do |http|
req = Net::HTTP::Get.new(uri)
http.request(req)
end