【问题标题】:SSL certs errors with Gem installGem 安装时出现 SSL 证书错误
【发布时间】:2023-04-11 09:33:02
【问题描述】:

我已经使用 https 设置了一个 gem 存储库。我们有内部签名证书,我有歌手/信任证书。

但是我不确定在哪里安装这些 pem 文件,因此在尝试进行 gem 安装时会出现 ssl 错误

我们正在使用 CHEF,因此使用作为 Chef 客户端安装的一部分安装的 ruby​​。

通过网络搜索,人们唯一知道的是一种解决方法,即从 https 更改为 http,但我希望 gem repo 设置为 HTTPS(端口 443)

以下是我得到的错误

[root@opslx0005 ~]# /opt/chef/embedded/bin/gem install lvm
ERROR:  Could not find a valid gem 'lvm' (>= 0) in any repository
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://myself.mydomain.com/artifactory/simple/infra-automation/gem-repo/latest_specs.4.8.gz)

尝试使用 Ruby remote_fetcher 进行测试

/opt/chef/embedded/bin/ruby -rrubygems/remote_fetcher -e 'p Gem::RemoteFetcher.new.fetch_http(URI.parse("https://myself.mydomain.com/artifactory/simple/infra-automation/gem-repo/latest_specs.4.8.gz")).bytesize'

更新:

在网上找到这个,这是我的默认 pem 文件,在这里更新了证书,但错误仍然没有发生

/opt/chef/embedded/bin/ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
/opt/chef/embedded/ssl/cert.pem

【问题讨论】:

    标签: ruby gem rubygems chef-infra


    【解决方案1】:

    最简单的解决方案可能是将SSL_CERT_FILE 环境变量设置为CA 证书文件。这应该由 Ruby 的 OpenSSL 层自动拾取。

    【讨论】:

    • 谢谢,试过了,还是不行。还是一样的错误
    【解决方案2】:

    从这里:SSL Error During Gem Installation (on MinGW64-MSys2)

    尝试下载http://curl.haxx.se/ca/cacert.pem 证书。然后,像这样指向一个特殊的环境变量:export SSL_CERT_FILE=~/cacert.pem 之后,发出更新命令:gem update --system 之后问题应该解决了。重新启动控制台并继续您的工作。

    【讨论】:

      【解决方案3】:

      我有同样的问题,以为是公司代理,但我只需要更新 ruby​​gems。 您可能想从https://github.com/rubygems/rubygems/releases/下载最新版本

      将其复制到 ruby​​ gems 文件夹 然后在cmd上

      C:\>gem install --local C:\rubygems-update-1.8.30.gem
      C:\>update_rubygems --no-ri --no-rdoc
      

      希望有帮助!

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-09-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-06-05
        • 2014-10-06
        • 2015-02-07
        • 1970-01-01
        相关资源
        最近更新 更多