Skip to content

Commit

Permalink
RUBY_DESCRIPTION, minor formatting, width
Browse files Browse the repository at this point in the history
  • Loading branch information
MSP-Greg committed May 30, 2020
1 parent eab2d8c commit e7cc891
Showing 1 changed file with 26 additions and 12 deletions.
38 changes: 26 additions & 12 deletions check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,16 @@
ssl_version = ARGV.shift
verify_mode = ARGV.any? ? OpenSSL::SSL.const_get(ARGV.shift) : OpenSSL::SSL::VERIFY_PEER

ruby_version = RUBY_VERSION.dup
ruby_version << "p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)
ruby_version << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION})"
ruby_version << " [#{RUBY_PLATFORM}]"
if defined?(RUBY_DESCRIPTION)
ruby_version = RUBY_DESCRIPTION
else
ruby_version = RUBY_VERSION.dup
ruby_version << "p#{RUBY_PATCHLEVEL}" if defined?(RUBY_PATCHLEVEL)
ruby_version << " (#{RUBY_RELEASE_DATE} revision #{RUBY_REVISION})"
ruby_version << " [#{RUBY_PLATFORM}]"
end

puts "Here's your Ruby and OpenSSL environment:"
puts "", "Here's your Ruby and OpenSSL environment:"
puts
puts "Ruby: %s" % ruby_version
puts "RubyGems: %s" % Gem::VERSION if defined?(Gem::VERSION)
Expand Down Expand Up @@ -110,14 +114,14 @@ def error_reason(error)
case error.message
# Check for certificate errors
when /certificate verify failed/
abort "Your Ruby can't connect to #{host} because you are missing the certificate " \
abort "Your Ruby can't connect to #{host} because you are missing the certificate\n" \
"files OpenSSL needs to verify you are connecting to the genuine #{host} servers."
# Check for TLS version errors
when /read server hello A/, /tlsv1 alert protocol version/
if ssl_version == "TLSv1_3"
abort "Your Ruby can't connect to #{host} because #{ssl_version} isn't supported yet."
else
abort "Your Ruby can't connect to #{host} because your version of OpenSSL is too old. " \
abort "Your Ruby can't connect to #{host} because your version of OpenSSL is too old.\n" \
"You'll need to upgrade your OpenSSL install and/or recompile Ruby to use a newer OpenSSL."
end
else
Expand All @@ -138,13 +142,23 @@ def error_reason(error)
guide_url = "http://ruby.to/ssl-check-failed"
if bundler_status =~ /success/ && rubygems_status =~ /success/
# Whoa, it seems like it's working!
puts "Hooray! This Ruby can connect to #{host}. You are all set to use Bundler and RubyGems. πŸ‘Œ"
puts "Hooray! This Ruby can connect to #{host}.",
"You are all set to use Bundler and RubyGems. πŸ‘Œ", ""
elsif rubygems_status !~ /success/
puts "It looks like Ruby and Bundler can connect to #{host}, but RubyGems itself cannot. You can likely solve this by manually downloading and installing a RubyGems update. Visit #{guide_url} for instructions on how to manually upgrade RubyGems. πŸ’Ž"
puts "It looks like Ruby and Bundler can connect to #{host}, but RubyGems itself",
"cannot. You can likely solve this by manually downloading and installing a",
"RubyGems update. Visit #{guide_url} for instructions on how to manually upgrade RubyGems. πŸ’Ž"
elsif bundler_status !~ /success/
puts "Although your Ruby installation and RubyGems can both connect to #{host}, Bundler is having trouble. The most likely way to fix this is to upgrade Bundler by running `gem install bundler`. Run this script again after doing that to make sure everything is all set. If you're still having trouble, check out the troubleshooting guide at #{guide_url} πŸ“¦"
puts "Although your Ruby installation and RubyGems can both connect to #{host},",
"Bundler is having trouble. The most likely way to fix this is to upgrade",
"Bundler by running `gem install bundler`. Run this script again after doing",
"that to make sure everything is all set. If you're still having trouble,",
"check out the troubleshooting guide at #{guide_url} πŸ“¦"
else
puts "For some reason, your Ruby installation can connect to #{host}, but neither RubyGems nor Bundler can. The most likely fix is to manually upgrade RubyGems by following the instructions at #{guide_url}. After you've done that, run `gem install bundler` to upgrade Bundler, and then run this script again to make sure everything worked. ❣️"
puts "For some reason, your Ruby installation can connect to #{host}, but neither",
"RubyGems nor Bundler can. The most likely fix is to manually upgrade RubyGems by",
"following the instructions at #{guide_url}. After you've done that, run `gem install",
"bundler` to upgrade Bundler, and then run this script again to make sure everything worked. ❣️"
end

def tls12_supported?
Expand All @@ -162,7 +176,7 @@ def tls12_supported?
unless tls12_supported?
puts
puts "WARNING: Although your Ruby can connect to #{host} today, your OpenSSL is very old! πŸ‘΄"
puts "WARNING: You will need to upgrade OpenSSL before January 2018 in order to keep using #{host}."
puts "WARNING: You will need to upgrade OpenSSL to use #{host}."
abort
end

Expand Down

0 comments on commit e7cc891

Please sign in to comment.