Jekyll -本地服务站点时,证书验证失败(无法获得本地颁发者证书)



我试图运行bundle exec jekyll serve在本地服务器上加载我的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:Ruby31-x64librubysite_ruby3.1.0rubygemsssl_certsrubygems.org我有GlobalSignRootCA和GlobalSignRootCA_R3

我还运行了SSL检查并收到了这个输出

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. 😡

我还更新了ruby gems并卸载/重新安装。仍然没有

这个问题的原因是因为Ruby使用的OpenSSL扩展不能与包含证书颁发机构的开放SSL库交互和编译。因此,您必须添加证书。Pem文件。(CA在CAcert中代表证书颁发机构)

更新:今天我开始再次解决这个问题,并找到了关于如何在本地服务jekyll站点时解决SSL证书问题的新指南。


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

首先,我下载了证书。pem文件(用于windows 10),然后我打开

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

,然后将variable value更改为我刚刚下载的新PEM文件的目录。'pathcacert.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开发者设置中生成一个新的PAT(个人访问令牌),并创建了一个名为JEKYLL_GITHUB_TOKEN的新环境变量,我将PAT保存到这个环境变量中,重新启动GIT Bash,并再次运行bundle exec jekyll serve,问题解决了。

相关内容

  • 没有找到相关文章

最新更新