gem install で certificate verify failed と出てgemがインストールできないのを直す

応急処置的だが。

こんなの出る

$ gem install rubocop
ERROR:  Could not find a valid gem 'rubocop' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.or│

g/latest_specs.4.8.gz)

updateもできない

$ gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError) 
    SSL_connect returned=1 errno=0 state=error: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

sourceからhttpsを消して、httpを入れる

$ gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources

$ gem sources -a http://rubygems.org/ 
https://rubygems.org is recommended for security over http://rubygems.org/

Do you want to add this insecure source? [yn]  y
http://rubygems.org/ added to sources

updateする

$ gem update --system
Updating rubygems-update
(snip)

RubyGems system software updated

sourceからhttpを消して、httpsを入れる

$ gem sources --remove http://rubygems.org/
http://rubygems.org/ removed from sources

$ gem sources -a https://rubygems.org/
https://rubygems.org/ added to sources

直った

$ gem install rubocop
Fetching: jaro_winkler-1.5.1.gem (100%)
(snip)