Ruby 在 Rails 无法验证 SSL 证书错误

Ruby On Rails Could not verify the SSL certificate Error

我使用 RVM 安装 Ruby On Rails on Ubuntu 18.04。 ruby-v:2.4.0 rails -v : 5.1.3

我尝试 运行 "bundle install" 命令,但出现以下错误。请为此提供最佳解决方案。

无法验证 https://rails-assets.org/ 的 SSL 证书。 您有可能遇到中间人攻击,但很可能您的系统没有所需的 CA 证书 确认。有关 OpenSSL 证书的信息,请参阅 'bit.ly/ruby-ssl'。要不使用 SSL 连接,请编辑您的 Gemfile 源和 将 'https' 更改为 'http'.

宝石文件

source 'https://rubygems.org'

git_source(:github) do |repo_name|
  repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/")
  "https://github.com/#{repo_name}.git"
end



# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 5.1.2'
# Use sqlite3 as the database for Active Record
#gem 'sqlite3'
gem 'pg'
# Use Puma as the app server
gem 'puma', '~> 3.7'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# See https://github.com/rails/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.2'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
gem 'jquery-turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.5'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
gem 'slim'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
gem 'sidekiq'
gem 'sidetiq'
gem 'sinatra', require: nil

gem 'draper'
gem 'simple_form'
gem 'active_interaction'

# gem 'postgres_ext', '~> 0.0.5'
gem 'devise', '> 4.x'
#gem 'devise', git: 'https://github.com/plataformatec/devise.git', branch: 'master'
#gem 'devise', git: 'https://github.com/gogovan/devise.git', branch: 'rails-5.1'
gem 'erubis'
gem 'activeadmin', '~> 1.0.0.pre'
gem 'inherited_resources', git: 'https://github.com/activeadmin/inherited_resources'
gem 'enumerize'
gem 'public_activity'
gem 'validate_url'
gem 'jquery-rails'
gem 'gon'
gem 'paperclip'
gem 'refile', require: 'refile/rails', github: 'refile/refile'
gem 'refile-mini_magick', github: 'refile/refile-mini_magick'
# gem 'aasm'
gem 'aasm', '~> 3.0', '>= 3.0.5'
gem 'normalize_attributes'
gem 'devise-async'
gem 'it'
gem 'recaptcha', require: 'recaptcha/rails'
gem 'refile-s3'
gem 'mime-types'
gem 'pundit', '~> 0.3'
gem 'responders'
gem 'unobtrusive_flash', '>=3'

gem 'omniauth'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'omniauth-twitter'
# gem 'fb_graph', '~> 2.7', '>= 2.7.17', git: 'https://github.com/nov/fb_graph.git', branch: 'master'
gem 'twitter'
gem 'shareable'
gem 'google-analytics-rails'


gem 'i18n-js'
gem 'foundation-rails'
gem 'nprogress-rails'
#gem 'wiselinks', '~> 1.2', '>= 1.2.1'
# gem 'wiselinks'
gem 'globalize', git: 'https://github.com/globalize/globalize'
gem 'devise-i18n'
gem 'high_voltage'
gem 'js-routes'
gem 'ahoy_matey','1.5.1'
#gem 'streamio-ffmpeg'
gem 'streamio-ffmpeg', '1.0.0'
#gem 'streamio-ffmpeg', '~> 2.0'
gem 'bundler', '>= 1.7.0'
gem 'sass'
gem 'sassc-rails'
#gem "active_model-errors_details"
#gem 'active_model-errors_details', '~> 1.3'
gem 'aws-sdk'
gem 'seedbank'
gem 'fog', require: 'fog/aws'
gem 'carrierwave'
gem 'ransack'
gem 'navigasmic'
gem 'ltree_hierarchy'
gem 'fontcustom'
gem 'memoist'
gem 'execjs'
gem 'therubyracer'
gem 'textacular'
gem 'flutie'
gem 'record_tag_helper', '~> 1.0'
gem 'friendly_id', '~> 5.1'

gem "hiredis", "~> 0.6.0"
gem "redis", ">= 3.2.0", :require => ["redis", "redis/connection/hiredis"]
gem "httpclient"

gem "closure_tree"
gem "bootstrap-sass"
gem "rails_emoji_picker"
# gem 'whenever', '~> 0.9.4'
gem 'elastic_transcoder'
gem 'crono'
gem 'daemons'


group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  # Adds support for Capybara system testing and selenium driver
  gem 'capybara', '~> 2.13'
  gem 'selenium-webdriver'


  gem 'pry-rails'
  gem 'pry-stack_explorer'
  gem 'rubocop'
  gem 'rspec-rails'
  gem 'factory_girl_rails'
  gem 'letter_opener', '~> 1.4.1'
end

source 'https://rails-assets.org' do
  gem 'rails-assets-jquery.tagsinput'
  gem 'rails-assets-video.js', '5.0.0.15'
  gem 'rails-assets-handlebars'
  gem 'rails-assets-jquery.dotdotdot'
  gem 'rails-assets-jsUri'
  gem 'rails-assets-jQuery-Storage-API'
  gem 'rails-assets-garlicjs'
  gem 'rails-assets-blueimp--jQuery-file-upload'
end


group :development do
  # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'

  gem 'capistrano', '~> 3.3.0'
  gem 'capistrano-rails'
  gem 'capistrano3-unicorn'
  gem 'capistrano-rvm'
  gem 'capistrano-sidekiq'


  #gem 'quiet_assets'


  gem 'yard'
  gem 'better_errors'
  gem 'bullet'
  gem 'thin'
  gem 'librarian-chef', require: false
  gem 'pghero'
  gem "airbrussh", require: false

  gem 'irbtools', require: 'irbtools/binding'
  gem 'irbtools-more', require: 'irbtools/binding'

end
group :test do
  gem 'shoulda-matchers'
  gem 'simplecov', require: false
  gem 'rspec-its'
  gem 'db-query-matchers'
  gem 'rspec-collection_matchers'
  gem 'test_after_commit'
  gem 'fakeredis'
  gem 'timecop'
  gem 'fivemat'
end

group :staging, :production do
  gem 'unicorn'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

我也将 'https' 更改为 'http' 但它不起作用。

今天我在使用我们的一个应用程序时遇到了同样的问题。我们使用 rails-assets-tether gem 来自 https://rails-assets.org. We notice that the same gem is available in the main repository (https://rubygems.org)。解决方案是从 Gemfile.

中删除 source

我认为如果您需要那些 gems,那么您必须等待证书更新(由网站所有者)或找到那些 gems 的替代来源。

更新:

你可以替换https://rails-assets.org with http://insecure.rails-assets.org。请记住在修复此问题后切换回 https 端点