Jekyll-证书验证失败(无法获得本地发行人证书)

发布于 2025-02-12 23:11:57 字数 4712 浏览 0 评论 0原文

我正在尝试运行捆绑电报Jekyll来加载我的jekyll网站在本地服务器上。当我使用此命令时,我会收到错误。

jekyll 3.9.2 | Error: SSL_connect returned=1 errno=0 peeraddr=140.82.113.9:443 state=error: certificate verify failed (unable to get local issuer certificate)C:/Ruby31-x64/lib/ruby/3.1.0/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=140.82.113.9:443 state=error: certificate verify failed (unable to get local issuer certificate) (OpenSSL::SSL::SSLError)
from C:/Ruby31-x64/lib/ruby/3.1.0/net/protocol.rb:46:in `ssl_socket_connect'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:1048:in `connect'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:976:in `do_start'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:965:in `start'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:627:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/downloader.rb:42:in `download'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/downloader.rb:24:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/munger.rb:24:in `munge!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme.rb:27:in `init'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme.rb:33:in `block in <top (required)>'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/hooks.rb:103:in `block in trigger'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/hooks.rb:102:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/hooks.rb:102:in `trigger'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/site.rb:105:in `reset'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/site.rb:68:in `process'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/command.rb:28:in `process_site'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:65:in `build'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:36:in `process'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:93:in `block in start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:93:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:93:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/exe/jekyll:15:in `<top (required)>'
        from C:/Ruby31-x64/bin/jekyll:32:in `load'
        from C:/Ruby31-x64/bin/jekyll:32:in `<main>'

我一直在研究使用SSL证书的使用,看来我缺少SSL证书。也许在我的c:/ruby31-x64/lib/ruby/3.1.0/net/文件中,提示我为什么从“消息”中收到所有其他“来自”消息。从我的理解中,SSL证书用于验证我试图连接到的服务器。

我检查了c:\ ruby​​31-x64 \ lib \ ruby​​ \ site_ruby \ 3.1.0 \ ruby​​gems \ ssl_certs \ ruby​​gems.org 而且我既有GlobalSignRootca and GlobalSignRootca_r3,

我还进行了SSL检查并接收了此OUPUT,

Here's your Ruby and OpenSSL environment:

Ruby:           3.1.2p20 (2022-04-12 revision 4491bb740a9506d76391ac44bb2fe6e483fec952) [x64-mingw-ucrt]
RubyGems:       3.3.17
Bundler:        2.3.16
Compiled with:  OpenSSL 1.1.1n  15 Mar 2022
Loaded version: OpenSSL 1.1.1n  15 Mar 2022
SSL_CERT_FILE:  C:/Ruby31-x64/ssl/cert.pem
SSL_CERT_DIR:   C:/Ruby31-x64/ssl/certs

With that out of the way, let's see if you can connect to rubygems.org...

Your Ruby can't connect to rubygems.org because you are missing the certificate files OpenSSL needs to verify you are connecting to the genuine rubygems.org servers.
Bundler connection to rubygems.org:       success ✅
RubyGems connection to rubygems.org:      success ✅
Ruby net/http connection to rubygems.org: failed  ❌

Unfortunately, this Ruby can't connect to rubygems.org. 
              

I am attempting to run bundle exec jekyll serve to load my jekyll site on a local server. When I use this command I receive error.

jekyll 3.9.2 | Error: SSL_connect returned=1 errno=0 peeraddr=140.82.113.9:443 state=error: certificate verify failed (unable to get local issuer certificate)C:/Ruby31-x64/lib/ruby/3.1.0/net/protocol.rb:46:in `connect_nonblock': SSL_connect returned=1 errno=0 peeraddr=140.82.113.9:443 state=error: certificate verify failed (unable to get local issuer certificate) (OpenSSL::SSL::SSLError)
from C:/Ruby31-x64/lib/ruby/3.1.0/net/protocol.rb:46:in `ssl_socket_connect'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:1048:in `connect'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:976:in `do_start'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:965:in `start'
        from C:/Ruby31-x64/lib/ruby/3.1.0/net/http.rb:627:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/downloader.rb:42:in `download'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/downloader.rb:24:in `run'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme/munger.rb:24:in `munge!'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme.rb:27:in `init'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-remote-theme-0.4.3/lib/jekyll-remote-theme.rb:33:in `block in <top (required)>'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/hooks.rb:103:in `block in trigger'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/hooks.rb:102:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/hooks.rb:102:in `trigger'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/site.rb:105:in `reset'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/site.rb:68:in `process'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/command.rb:28:in `process_site'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:65:in `build'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/build.rb:36:in `process'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:93:in `block in start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:93:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:93:in `start'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/lib/jekyll/commands/serve.rb:75:in `block (2 levels) in init_with_program'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `block in execute'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `each'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/command.rb:220:in `execute'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary/program.rb:42:in `go'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mercenary-0.3.6/lib/mercenary.rb:19:in `program'
        from C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/jekyll-3.9.2/exe/jekyll:15:in `<top (required)>'
        from C:/Ruby31-x64/bin/jekyll:32:in `load'
        from C:/Ruby31-x64/bin/jekyll:32:in `<main>'

I have been researching the use of SSL certificates and it seems that I am missing an ssl certificate. Perhaps in my C:/Ruby31-x64/lib/ruby/3.1.0/net/ files suggesting why I am receiving all those additional "from" messages. From my understanding an SSL certificate is used in verifying the server which I am attempting to connect to.

I checked C:\Ruby31-x64\lib\ruby\site_ruby\3.1.0\rubygems\ssl_certs\rubygems.org
and I have both GlobalSignRootCA and GlobalSignRootCA_R3

I also ran an SSL check and received this ouput

Here's your Ruby and OpenSSL environment:

Ruby:           3.1.2p20 (2022-04-12 revision 4491bb740a9506d76391ac44bb2fe6e483fec952) [x64-mingw-ucrt]
RubyGems:       3.3.17
Bundler:        2.3.16
Compiled with:  OpenSSL 1.1.1n  15 Mar 2022
Loaded version: OpenSSL 1.1.1n  15 Mar 2022
SSL_CERT_FILE:  C:/Ruby31-x64/ssl/cert.pem
SSL_CERT_DIR:   C:/Ruby31-x64/ssl/certs

With that out of the way, let's see if you can connect to rubygems.org...

Your Ruby can't connect to rubygems.org because you are missing the certificate files OpenSSL needs to verify you are connecting to the genuine rubygems.org servers.
Bundler connection to rubygems.org:       success ✅
RubyGems connection to rubygems.org:      success ✅
Ruby net/http connection to rubygems.org: failed  ❌

Unfortunately, this Ruby can't connect to rubygems.org. ????

I also updated ruby gems and uninstalled/reinstalled. Still nothing

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

窗影残 2025-02-19 23:11:58

此问题的原因是因为Ruby使用的OPENSL扩展名不会与包含证书授权的开放SSL库进行交互和编译。因此,您必须自己添加cacert.pem文件。 (CA中的CACERT代表证书机构)

更新:今天,我再次开始解决这个问题,并在当地服务Jekyll网站时如何解决了如何解决SSL证书问题的新指南。

请参阅此处:
https://github.com/mzlogin/mzlogin.github.io/wiki/wiki/problems-and-solutions-and-solutions-when-run-jekyll-on-windows

首先,我下载了cacert.pem文件(我下载了cacert.pem file(我)对于Windows 10),然后打开

系统 - &gt;高级系统设置 - &GT;环境变量 - &gt;系统变量 - &gt;选择的'ssl_cert_file'

,然后将变量值更改为我刚下载的新PEM文件的目录。 'Path \ cacert.pem'

之后,我重新启动了git bash,并尝试第二次运行bundle exec jekyll serve。这次是通过不同的错误。

 Liquid Exception: The GitHub API credentials you provided aren't valid. in /_layouts/default.html

从这里,我找到了这个网站,这很有帮助。
http://blog.johannesmp.com/2017/02/13/fixing-jekyll-serve-on-windows/

我继续从Github开发人员设置和Github开发人员设置和创建了一个名为jekyll_github_token的新环境变量,我将pat保存到了此环境变量,重新启动的git bash和ran 捆绑exec jekyll serve,解决问题。

The reason for this problem is because the OpenSSL extension which Ruby uses does not interact and compile with an Open SSL Library which includes Certificate Authorities. So you must add the CAcert.pem file yourself. (CA in CAcert stands for certificate authorities)

UPDATE: Today I began plugging away at the problem again and have found new guides on how to solve SSL certificate problems when serving jekyll sites locally.

See here:
https://github.com/mzlogin/mzlogin.github.io/wiki/Problems-and-solutions-when-run-Jekyll-on-Windows

First, I downloaded the cacert.pem file (for windows 10) then I opened

system -> advanced system settings -> environment variables -> System variables -> selected 'SSL_CERT_FILE'

and then changed the variable value to the directory of my new PEM file which I just downloaded. 'path\cacert.pem'

After this, I restarted Git Bash and tried to run bundle exec jekyll serve for a second time. This time it through a different error.

 Liquid Exception: The GitHub API credentials you provided aren't valid. in /_layouts/default.html

From here I found this website, which has been helpful.
http://blog.johannesmp.com/2017/02/13/fixing-jekyll-serve-on-windows/

I continued to generate a new PAT (personal access token) from github developer settings and created a new environment variable named JEKYLL_GITHUB_TOKEN I saved the PAT into this environment variable, restarted GIT Bash, and ran bundle exec jekyll serve again, problem solved.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文