24
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed

Last updated at Posted at 2014-12-02

rbenv + ruby2.1の環境で,berkshelfでクックブックを取得しようとしたところ、表題のエラーが。内容は、証明書の検証がうまくいっていないというもの。原因は、検証に利用するCA証明書の指定ががうまくいっていないことが原因。

参考:http://d.hatena.ne.jp/riocampos+tech/20140408/ruby_reinstall_caused_by_openssl_vulnerability

やったこと

#opensslアップデート
$brew update
$brew upgrade openssl
$brew link openssl --force

#rbenvのrubyを再インストール
$env CONFIGURE_OPTS="--with-readline-dir=`brew --prefix readline` --with-openssl-dir=`brew --prefix openssl`" rbenv install -f 2.1.2

#バージョン指定
$rbenv local 2.1.2

#rubyで読み込むCA証明書のパス確認
$ruby -ropenssl -e "p OpenSSL::X509::DEFAULT_CERT_FILE"
# => "/usr/local/etc/openssl/cert.pem" 

#最新のCA証明書を取得し、上記パスに保存
#参考http://railsapps.github.io/openssl-certificate-verify-failed.html
$curl -O http://curl.haxx.se/ca/cacert.pem
$sudo mv cacert.pem /usr/local/etc/openssl/cert.pem

#環境変数SSL_CERT_FILEの設定

$echo "export SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem" >> ~/.bash_profile

#設定読み込み
$source ~/.bash_profile

#確認
$env | grep SSL_CERT_FILE
SSL_CERT_FILE=/usr/local/etc/openssl/cert.pem

24
25
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
24
25

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?