配置Vagrant CA证书

24
我在公司代理服务器和自签名CA证书后面执行Vagrant命令时遇到了问题。我已经配置了环境变量HTTP_PROXY、HTTPS_PROXY和HTTP_NO_PROXY变量。
我有一个包含所有公司证书的Java密钥库。我使用keytool命令的-exportcert选项以及众多选项。我还使用了openssl命令,也采用了多种选项,并将生成的文件放置在Vagrant安装中嵌入的Ruby目录中的多个位置,但都没有成功。
我阅读了很多关于配置Ruby和curl的网站,但都没有成功让Vagrant命令工作。我找到的所有帖子都集中在Ruby和curl选项上,我不知道如何在Vagrant中使用它们,其中包括Ruby作为Vagrant的嵌入式组件。
请提供正确导出Java密钥库中证书的说明,可选地转换它们并将生成的文件放置在Vagrant中,以便Vagrant能够通过公司代理成功连接到互联网。
Windows 7上的Vagrant 1.9.5
Vagrant安装目录C:\Apps\Vagrant\
C:\WorkArea> vagrant plugin install vagrant.proxyconf

ERROR:  SSL verification error at depth 3: self signed certificate in certificate chain (19)
ERROR:  Root certificate is not trusted (/C=US/O=xxx xxx/OU=xxx xxx Certification Authority/CN=xxx xxx Root Certification Authority 01 G2)  
SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

C:\WorkArea> vagrant up

Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'puppetlabs/ubuntu-16.04-64-puppet' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
The box 'puppetlabs/ubuntu-16.04-64-puppet' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://atlas.hashicorp.com/puppetlabs/ubuntu-16.04-64-puppet"]
Error: SSL certificate problem: self signed certificate in certificate chain
More details here: http://curl.haxx.se/docs/sslcerts.html
curl performs SSL certificate verification by default, using a "bundle"
of Certificate Authority (CA) public keys (CA certs). If the default
bundle file isn't adequate, you can specify an alternate file
using the --cacert option.
If this HTTPS server uses a certificate signed by a CA represented in
the bundle, the certificate verification probably failed due to a
problem with the certificate (it might be expired, or the name might
not match the domain name in the URL).
If you'd like to turn off curl's verification of the certificate, use
the -k (or --insecure) option.

你能分享一下你的 Vagrantfile 信息吗? - Hara
1个回答

18
您并没有说明您尝试修复问题所采取的步骤,但似乎您没有将根证书放置在正确位置

前往安装Vagrant的目录,找到文件embedded\cacert.pem,然后将您公司证书的内容追加到该文件中。保存并重试操作。如果您正确导出了根CA证书,则它们应该被Vagrant读取并允许连接。

如果您仍无法通过合并文件使其正常工作,请在环境中使用SSL_CERT_FILE=/path/to/your/certs.pem运行vagrant。这将允许您验证您是否已正确导出公司证书。


7
这应该是回答这个问题的答案。关于如何导出证书需要做一些澄清。在Windows中,使用Internet Explorer浏览器,您可以按照以下步骤进行操作:Internet选项 > 内容选项卡 > 证书按钮 > 受信任的根证书颁发机构选项卡 > 选择您的证书 > 导出按钮 > 下一步 > Base-64编码的X.509 > 选择文件位置/名称 > 下一步 > 完成。右键单击文件,在您选择的文本编辑器中打开文件并复制数据,然后粘贴到您的 embedded\cacert.pem 文件的末尾。之后,我必须通过控制台登录vagrant,然后才能运行 vagrant up - fujiiface
虚拟问题,有没有办法知道我的企业证书是什么?还是IT部门应该提供它们? - Eddy Hernandez
请向您的IT部门咨询。 - anothermh
我真的非常希望Vagrant默认情况下能够信任操作系统信任存储中的所有证书,就像大多数应用程序一样,或者至少公开详细说明整个解决过程。 - Alexander Gonchiy

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接