ruby - 当使用 rvm ruby​​ 3.0.0 OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed

标签 ruby openssl rvm

描述

您好,我们在 macos-big sur AWS ec2 机器上使用 rvm,但似乎 rvm 和 openssl 存在问题

重现步骤

我们通过packer安装了rvm和ruby

brew install gpg2
echo " ------------------ GPG2 Installation completed -----------------------"
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
source ~/.bash_profile && rvm install "ruby-3.0.0"

看起来不错

rvm use 3.0.0
openssl version
which openssl

Using /Users/ec2-user/.rvm/gems/ruby-3.0.0 /usr/bin/openssl LibreSSL 2.8.3

但是当我

git clone https://github.com/mislav/ssl-tools.git
ruby ssl-tools/doctor.rb

我得到一个错误

Using /Users/ec2-user/.rvm/gems/ruby-3.0.0 /Users/ec2-user/.rvm/rubies/ruby-3.0.0/bin/ruby (3.0.0-p0) OpenSSL 1.1.1m 14 Dec 2021: /usr/local/etc/openssl@1.1 SSL_CERT_DIR="" SSL_CERT_FILE=""

HEAD https://status.github.com:443 OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed (unable to get local issuer certificate)

The server presented a certificate that could not be verified: subject: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert SHA2 High Assurance Server CA issuer: /C=US/O=DigiCert Inc/OU=www.digicert.com/CN=DigiCert High Assurance EV Root CA error code 20: unable to get local issuer certificate

Possible causes: /usr/local/etc/openssl@1.1/cert.pem' does not exist /usr/local/etc/openssl@1.1/certs/' is empty

当我

brew doctor

我明白了

Using /Users/ec2-user/.rvm/gems/ruby-3.0.0 Please note that these warnings are just used to help the Homebrew maintainers with debugging if you file an issue. If everything you use Homebrew for is working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: Homebrew's "sbin" was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin. Consider setting your PATH for example like so: echo 'export PATH="/usr/local/sbin:$PATH"' >> ~/.zshrc

Warning: Broken symlinks were found. Remove them with brew cleanup: /usr/local/etc/gnutls/cert.pem /usr/local/etc/openssl@1.1/cert.pem

github.com/rvm 中问了同样的问题

最佳答案

这是有效的解决方案

在 ~/.bashrc 中

# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

在 ~/.bash_profile

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*

在 ~/.zshrc 中

# Avoid warning: Homebrew's "sbin" was not found in your PATH but you have installed formulae that put executables in /usr/local/sbin
export PATH="/usr/local/sbin:$PATH"
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"

在提供者中

# Remove broken symlinks before using brew
/usr/local/bin/brew cleanup

/usr/local/bin/brew install gpg2
echo "------------------ GPG2 Installation completed -----------------"
curl -sSL https://rvm.io/mpapis.asc | /usr/local/bin/gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | /usr/local/bin/gpg --import -
curl -sSL https://get.rvm.io | bash -s stable --auto-dotfiles
source ~/.bash_profile

关于ruby - 当使用 rvm ruby​​ 3.0.0 OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=error: certificate verify failed,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70984890/

相关文章:

c++ - "error: expected unqualified-id before ' 。 '"使用 OpenSSL 库编译 C++ 应用程序

c++ - 如果我放弃哈希计算,是否必须调用 SHA1_Final()?

ruby-on-rails - 在 Mac OS X Sierra 上设置 RVM、Ruby : Unable to require openssl

ruby-on-rails - Heroku 301 重定向

sql - 查找给定日期范围、持续时间和不可用日期列表的可用公寓

ssl - 为什么 OpenSSL 中的 BIO_do_connect() 不能与 GDAX(又名 cloudflare)沙箱一起正常工作?

ruby - 不小心更改了我的 gem 安装位置

rvm - 使用 capistrano 和 rvm-capistrano 进行部署

mysql - 使用大写 ID 从 Rails 应用程序保存 MYSQL 数据库中:Mysql2::Error: Field 'ID' 没有默认值

ruby - 从 Ruby 文件调用 faSTLane 函数