gpt4 book ai didi

ruby - SSL_connect 返回=1 错误号=0 状态=错误 : certificate verify failed in ruby and Ubuntu 14. 04

转载 作者:行者123 更新时间:2023-12-05 01:53:11 26 4
gpt4 key购买 nike

我有一个与第三方网络服务集成的 Rails 应用程序。自最初开发多年以来,它一直运行良好。由于一些意想不到的原因,它突然停止工作了。我会说我们没有更改代码中的任何内容。唯一可能相关的是我们的 Letsencrypt SSL 证书已过期并且我们更新了它。

事实是我在调用网络服务请求时遇到了这个错误:

E, [2022-02-17T19:53:25.385435 #32501] ERROR -- : SSL_connect returned=1 errno=0 state=error: certificate verify failed
E, [2022-02-17T19:53:25.385876 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/httpi-2.4.4/lib/httpi/adapter/httpclient.rb:28:in `rescue in request'
E, [2022-02-17T19:53:25.386103 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/httpi-2.4.4/lib/httpi/adapter/httpclient.rb:24:in `request'
E, [2022-02-17T19:53:25.386358 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/httpi-2.4.4/lib/httpi.rb:161:in `request'
E, [2022-02-17T19:53:25.386658 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/httpi-2.4.4/lib/httpi.rb:127:in `get'
E, [2022-02-17T19:53:25.386909 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/wasabi-3.5.0/lib/wasabi/resolver.rb:43:in `load_from_remote'
E, [2022-02-17T19:53:25.387150 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/wasabi-3.5.0/lib/wasabi/resolver.rb:33:in `resolve'
E, [2022-02-17T19:53:25.387349 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/wasabi-3.5.0/lib/wasabi/document.rb:142:in `xml'
E, [2022-02-17T19:53:25.387606 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/wasabi-3.5.0/lib/wasabi/document.rb:160:in `parse'
E, [2022-02-17T19:53:25.387887 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/wasabi-3.5.0/lib/wasabi/document.rb:147:in `parser'
E, [2022-02-17T19:53:25.388162 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/wasabi-3.5.0/lib/wasabi/document.rb:64:in `soap_actions'
E, [2022-02-17T19:53:25.388432 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/savon-2.12.0/lib/savon/operation.rb:22:in `ensure_exists!'
E, [2022-02-17T19:53:25.388696 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/savon-2.12.0/lib/savon/operation.rb:15:in `create'
E, [2022-02-17T19:53:25.388955 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/savon-2.12.0/lib/savon/client.rb:32:in `operation'
E, [2022-02-17T19:53:25.389214 #32501] ERROR -- : /Users/Rober/.rvm/gems/ruby-2.4.9/gems/savon-2.12.0/lib/savon/client.rb:36:in `call'

我对证书一点都不熟练。所以,我找到了这篇文章:SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed基本上我尝试了几乎所有我看到的东西,但没有任何效果。

生产环境在 Ubuntu 14.04.6 LTS (GNU/Linux 3.13.0-36-generic x86_64) 下运行 AWS EC2 实例。

根据我的阅读,它可能与 ruby​​ 中的 SSL 库有关。这是有道理的,因为我注意到我在使用 ruby​​ 在我的 webapp 中请求时遇到了这个错误,但是如果我请求使用 curl,比如 curl --header "Content-Type: text/xml;charset=UTF- 8"--data @request.xml https://www.booking-manager.com/cbm_web_service2/services/CBM 我得到了一个成功的数据响应。

关于我的 ruby​​ 环境:

rvm info

ruby-2.4.9:

system:
uname: "Linux ip-172-31-20-213 3.13.0-36-generic #63-Ubuntu SMP Wed Sep 3 21:30:07 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux"
name: "Ubuntu"
version: "14.04"
architecture: "x86_64"
bash: "/bin/bash => GNU bash, version 4.3.11(1)-release (x86_64-pc-linux-gnu)"
zsh: " => not installed"
remote_path: "ubuntu/14.04/x86_64"

rvm:
version: "1.29.12 (manual)"
updated: "2 months 20 days 19 hours 54 minutes 44 seconds ago"
path: "/usr/share/rvm"
autolibs: "[4] Allow RVM to use package manager if found, install missing dependencies, install package manager (only OS X)."

ruby:
interpreter: "ruby"
version: "2.4.9p362"
date: "2019-10-02"
platform: "x86_64-linux"
patchlevel: "2019-10-02 revision 67824"
full_version: "ruby 2.4.9p362 (2019-10-02 revision 67824) [x86_64-linux]"

homes:
gem: "/home/ubuntu/.rvm/gems/ruby-2.4.9"
ruby: "/usr/share/rvm/rubies/ruby-2.4.9"

binaries:
ruby: "/usr/share/rvm/rubies/ruby-2.4.9/bin/ruby"
irb: "/usr/share/rvm/rubies/ruby-2.4.9/bin/irb"
gem: "/usr/share/rvm/rubies/ruby-2.4.9/bin/gem"
rake: "/home/ubuntu/.rvm/gems/ruby-2.4.9/bin/rake"

environment:
PATH: "/home/ubuntu/.rvm/gems/ruby-2.4.9/bin:/home/ubuntu/.rvm/gems/ruby-2.4.9@global/bin:/usr/share/rvm/rubies/ruby-2.4.9/bin:/usr/share/rvm/bin:/home/ubuntu/.rbenv/plugins/ruby-build/bin:/home/ubuntu/.rbenv/shims:/home/ubuntu/.rbenv/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
GEM_HOME: "/home/ubuntu/.rvm/gems/ruby-2.4.9"
GEM_PATH: "/home/ubuntu/.rvm/gems/ruby-2.4.9:/home/ubuntu/.rvm/gems/ruby-2.4.9@global"
MY_RUBY_HOME: "/usr/share/rvm/rubies/ruby-2.4.9"
IRBRC: "/usr/share/rvm/rubies/ruby-2.4.9/.irbrc"
RUBYOPT: ""
gemset: ""

我的 web 应用程序在 nginx 前端下运行,向在 Puma 下运行的 ruby​​ on rails 发送请求。我的美洲狮版本:

puma -v
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/puma_http11.so: [BUG] Segmentation fault at 0x00000000000640
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

-- Control frame information -----------------------------------------------
c:0022 p:-17524110008176 s:0109 e:000108 TOP [FINISH]
c:0021 p:---- s:0107 e:000106 CFUNC :require
c:0020 p:0115 s:0103 e:000102 METHOD /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0019 p:0087 s:0093 e:000092 TOP /home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/server.rb:15 [FINISH]
c:0018 p:---- s:0091 e:000090 CFUNC :require
c:0017 p:0115 s:0087 e:000086 METHOD /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0016 p:0007 s:0077 e:000076 TOP /home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/runner.rb:3 [FINISH]
c:0015 p:---- s:0075 e:000074 CFUNC :require
c:0014 p:0115 s:0071 e:000070 METHOD /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0013 p:0007 s:0061 e:000060 TOP /home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/cluster.rb:3 [FINISH]
c:0012 p:---- s:0059 e:000058 CFUNC :require
c:0011 p:0115 s:0055 e:000054 METHOD /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0010 p:0023 s:0045 e:000044 TOP /home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/launcher.rb:5 [FINISH]
c:0009 p:---- s:0043 e:000042 CFUNC :require
c:0008 p:0115 s:0039 e:000038 METHOD /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0007 p:0039 s:0029 e:000028 TOP /home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/cli.rb:8 [FINISH]
c:0006 p:---- s:0027 e:000026 CFUNC :require
c:0005 p:0115 s:0023 e:000022 METHOD /home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55
c:0004 p:0007 s:0013 e:000012 TOP /home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/bin/puma:6 [FINISH]
c:0003 p:---- s:0010 e:000009 CFUNC :load
c:0002 p:0135 s:0006 E:001c18 EVAL /home/ubuntu/.rbenv/versions/2.1.2/bin/puma:23 [FINISH]
c:0001 p:0000 s:0002 E:0019f8 TOP [FINISH]

-- Ruby level backtrace information ----------------------------------------
/home/ubuntu/.rbenv/versions/2.1.2/bin/puma:23:in `<main>'
/home/ubuntu/.rbenv/versions/2.1.2/bin/puma:23:in `load'
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/bin/puma:6:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/cli.rb:8:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/launcher.rb:5:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/cluster.rb:3:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/runner.rb:3:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rvm/gems/ruby-2.4.9/gems/puma-4.3.0/lib/puma/server.rb:15:in `<top (required)>'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
/home/ubuntu/.rbenv/versions/2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
...

[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html

Aborted (core dumped)

我正在尝试连接到第三方网络服务:

client = Savon.client(wsdl: "https://www.booking-manager.com/cbm_web_service2/services/CBM", 
#log_level: :info,
log_level: :debug,
log: true,
pretty_print_xml: true,
open_timeout: 300,
read_timeout: 300)
message = {'in0' => Yanpy::MMK_USER_ID,
'in1' => Yanpy::MMK_USERNAME,
'in2' => Yanpy::MMK_PASSWORD}
response = client.call(:get_regions, message: message)

更新根据下面@jangaraj 提供的答案,我可以在开发环境中解决问题:Error Certificate verify failed (certificate has expired)): in Mac OSX 11.6.1 and ruby 3.0.3 .但是,我仍然无法解决生产中的问题。我认为根本原因是在使用正确的 ca-certificates 文件更新我的 Web 服务请求之前,我需要清楚这个文件在哪里以及它是否工作。为此,再次根据我在另一篇开发文章中遵循的步骤,运行:

openssl s_client -showcerts -host valid-isrgrootx1.letsencrypt.org -port 443

我可以按照 https://community.letsencrypt.org/t/help-thread-for-dst-root-ca-x3-expiration-september-2021/149190/970 中的步骤调试和修复 ca 证书配置但是,目前这对我不起作用。我看到一些杂乱的 ca-certs 文件夹和文件,可能来自不同的安装?我试着解释一下:

  • /usr/share/ca-certificates/mozilla :我有一个 .crt 文件列表。 DST_Root_CA_X3.crt 已删除,ISRG_Root_X1.crt 存在。
  • /etc/ca-certificates/update.d 为空。
  • /etc/ca-certificates.conf 包含 ca 证书列表。我可以看到 #mozilla/DST_Root_CA_X3.crt 已评论并且 mozilla/ISRG_Root_X1.crt 可用。
  • 前面的文件提到 ca-certs 安装在/etc/ssl/certs 中,我可以在其中看到上面/usr/share/ca-certificates/mozilla 文件夹的模拟链接列表。请注意,有一个指向 DST_Root_CA_X3.crt 的文件/链接已被删除。另一方面,我可以看到:
  1. ISRG_Root_X1.pem ->/usr/share/ca-certificates/mozilla/ISRG_Root_X1.crt
  2. 4042bcee.0 -> ISRG_Root_X1.pem
  3. 6187b673.0 -> ISRG_Root_X1.pem
  • 但除此之外,我还可以在/etc/ssl/certs 中看到一个 ca-certificates.crt,其中包含格式如下的证书列表:

    -----开始证书-----...-----证书结束-----

  • /usr/lib/ssl/certs 似乎拥有与/etc/ssl/certs 相同的证书。

事实是,当我运行 openssl s_client -showcerts -host valid-isrgrootx1.letsencrypt.org -port 443 时,我仍然会遇到下一个错误:

CONNECTED(00000003)
depth=2 C = US, O = Internet Security Research Group, CN = ISRG Root X1
verify error:num=20:unable to get local issuer certificate
verify return:0
---
Certificate chain
0 s:/CN=origin.letsencrypt.org
i:/C=US/O=Let's Encrypt/CN=R3
-----BEGIN CERTIFICATE-----
MIIFMTCCBBmgAwIBAgISAz+qxNSV9WDWFPKhpVo1EzpqMA0GCSqGSIb3DQEBCwUA
MDIxCzAJBgN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w6W4
avAuvDszue5L3sz85K+EC4Y/wFVDNvZo4TYXao6Z0f+lQKc0t8DQYzk1OXVu8rp2
yJMC6alLbBfODALZvYH7n7do1AZls4I9d1P4jnkDrQoxB3UqQ9hVl3LEKQ73xF1O
yK5GhDDX8oVfGKF5u+decIsH4YaTw7mP3GFxJSqv3+0lUFJoi5Lc5da149p90Ids
hCExroL1+7mryIkXPeFM5TgO9r0rvZaBFOvV2z0gp35Z0+L4WPlbuEjN/lxPFin+
HlUjr8gRsI3qfJOQFy/9rKIJR0Y/8Omwt/8oTWgy1mdeHmmjk7j1nYsvC9JSQ6Zv
MldlTTKB3zhThV1+XWYp6rjd5JW1zbVWEkLNxE7GJThEUG3szgBVGP7pSWTUTsqX
nLRbwHOoq7hHwg==
-----END CERTIFICATE-----
2 s:/C=US/O=Internet Security Research Group/CN=ISRG Root X1
i:/O=Digital Signature Trust Co./CN=DST Root CA X3
-----BEGIN CERTIFICATE-----
MIIFYDCCBEigAwIBAgIQQAF3ITfU6UK47naqPGQKtzANBgkqhkiG9w0BAQsFADA/
MSQwIgYDVQQKExtEaWdpdGFsIFNpZ25hdHVyZSBUcnVzdCBDby4xFzAVBgNVBAMT
DkRTVCBSb290IENBIFgzMB4XDTIxMDEyMDE5MTQwM1oXDTI0MDkzMDE4MTQwM1ow
TzELMAkGA1UEBhMCVVMxKTAnBgNVBAoTIEludGVybmV0IFNlY3VyaXR5IFJlc2Vh
cmNoIEdyb3VwMRUwEwYDVQQDEwxJU1JHIFJvb3QgWDEwggIiMA0GCSqGSIb3DQEB
AQUAA4ICDwAwggIKAoICAQCt6CRz9BQ385ueK1coHIe+3LffOJCMbjzmV6B493XC
ov71am72AE8o295ohmxEk7axY/0UEmu/H9LqMZshftEzPLpI9d1537O4/xLxIZpL
wYqGcWlKZmZsj348cL+tKSIG8+TA5oCu4kuPt5l+lAOf00eXfJlII1PoOK5PCm+D
LtFJV4yAdLbaL9A4jXsDcCEbdfIwPPqPrt3aY6vrFk/CjhFLfs8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P52GE24HGNtLi1qoJFlcDyqSMo59ahy2cI2qBDLKobkx/J3vWraV0T9VuG
WCLKTVXkcGdtwlfFRjlBz4pYg1htmf5X6DYO8A4jqv2Il9DjXA6USbW1FzXSLr9O
he8Y4IWS6wY7bCkjCWDcRQJMEhg76fsO3txE+FiYruq9RUWhiF1myv4Q6W+CyBFC
Dfvp7OOGAN6dEOM4+qR9sdjoSYKEBpsr6GtPAQw4dy753ec5
-----END CERTIFICATE-----
---
Server certificate
subject=/CN=origin.letsencrypt.org
issuer=/C=US/O=Let's Encrypt/CN=R3
---
No client certificate CA names sent
---
SSL handshake has read 4700 bytes and written 421 bytes
---
New, TLSv1/SSLv3, Cipher is ECDHE-RSA-AES128-GCM-SHA256
Server public key is 2048 bit
Secure Renegotiation IS supported
Compression: NONE
Expansion: NONE
SSL-Session:
Protocol : TLSv1.2
Cipher : ECDHE-RSA-AES128-GCM-SHA256
Session-ID: 1DA772568CC98B40026497CB0013ABD22F5F2D9142370B99017A3C84EAEBC0BD
Session-ID-ctx:
Master-Key: C0324E0CDC2FEA59C3A921E1CDCBED19DD7EF2D4785B4BC8208B18934E1E8FA646692F3AAB956CFA2646015AEB3A6AAB
Key-Arg : None
PSK identity: None
PSK identity hint: None
SRP username: None
TLS session ticket lifetime hint: 86400 (seconds)
TLS session ticket:
0000 - a7 64 6c 88 3c 76 89 cf-37 95 cd b6 5f 84 c3 71 .dl.<v..7..._..q
0010 - de ca 95 74 f3 f8 9f 08-eb bc e7 be a5 63 ca e4 ...t.........c..
0020 - 1e 80 c9 a6 a7 bd fe 9e-a0 ae f7 f1 64 74 b3 ff ............dt..
0030 - e2 8d 1e 2a 51 0a 5a f5-77 6d 86 b6 87 28 a1 2a ...*Q.Z.wm...(.*
0040 - e0 ff 79 d8 d5 89 52 99-a7 50 ca 35 62 30 97 f9 ..y...R..P.5b0..
0050 - 24 57 b3 e5 87 4a 60 04-c2 e9 45 c7 47 cd b9 a9 $W...J`...E.G...
0060 - b2 d5 f9 82 05 f6 98 5f-54 4a 5e 4a f5 06 66 da ......._TJ^J..f.
0070 - e6 ba 13 ff 66 ff a3 3a-b7 1c db fa 05 ad 51 0f ....f..:......Q.
0080 - ba ad fe 92 ea e7 c6 92-02 89 ec 83 06 46 06 2d .............F.-
0090 - 1b 96 95 81 80 4a eb 55-b1 80 6a 5d e6 09 78 75 .....J.U..j]..xu
00a0 - fe a9 c2 d8 d2 e2 31 a5-77 c5 d2 e2 c9 3b d0 01 ......1.w....;..

Start Time: 1646907242
Timeout : 300 (sec)
Verify return code: 20 (unable to get local issuer certificate)
---

因此,DST Root CA X3 似乎存在于某处。我卡在了这一点上。

openssl version
OpenSSL 1.0.1f 6 Jan 2014

如果我运行:

ubuntu@ip-172-31-9-63:~$ irb
2.1.4 :001 > require "openssl"
=> true
2.1.4 :002 > puts OpenSSL::OPENSSL_VERSION
OpenSSL 1.0.1f 6 Jan 2014
=> nil
2.1.4 :003 > puts "SSL_CERT_FILE: %s" % OpenSSL::X509::DEFAULT_CERT_FILE
SSL_CERT_FILE: /usr/lib/ssl/cert.pem
=> nil
2.1.4 :004 > puts "SSL_CERT_DIR: %s" % OpenSSL::X509::DEFAULT_CERT_DIR
SSL_CERT_DIR: /usr/lib/ssl/certs
=> nil

但是/usr/lib/ssl/cert.pem 不存在。

此外,如果我这样做:

openssl version -d

我得到:OPENSSLDIR: "/usr/lib/ssl"

更新为了分开这些问题,我在这里创建了一个关于当前问题的新帖子:Removing old Digital Signature Trust Co./CN=DST Root CA X3 throwing error verify error:num=20:unable to get local issuer certificate in Ubuntu Part 1我想一旦它修复了,我就能在这篇文章中修复它。

最佳答案

看起来您使用的是 Ubuntu 14 和 Savon 2 客户端。Savon 2 客户端文档:https://www.savonrb.com/version2/globals.html

ssl_ca_cert_file

Sets the SSL ca cert file to use.

Savon.client(ssl_ca_cert_file: "lib/ca_cert.pem")

我会将 ssl_ca_cert_file 明确指向 /etc/ssl/certs/ca-certificates.crt

确保您的操作系统具有有效的 CA 证书:

apt-get update -y
apt --only-upgrade install -y ca-certificates
update-ca-certificates

Ruby 使用的旧 OpenSSL 版本也可能存在问题。

关于ruby - SSL_connect 返回=1 错误号=0 状态=错误 : certificate verify failed in ruby and Ubuntu 14. 04,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71164059/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com