流浪汉不在Windows上工作

时间:2015-10-04 20:22:59

标签: curl vagrant virtualbox

我正在关注官方的流浪文件 https://docs.vagrantup.com/v2/getting-started/index.html

我在Windows 10 64位处理器上安装了vagrant和virtual box。 在命令提示符下运行这些命令后,我得到:

vagrant init hashicorp/precise32
vagrant up

错误如下所示: 使用'virtualbox'提供程序将计算机'默认'打开... ==>默认值:无法找到Box'hashicorp / precise32'。试图找到并安装......     默认值:Box Provider:virtualbox     默认值:Box版本:> = 0 无法找到“hashicorp / precise32”框或 无法在远程目录中访问。如果这是私人的 在HashiCorp的Atlas上,请确认您已登录 vagrant login。另外,请仔细检查名称。扩大了 URL和错误消息如下所示:

网址:[“https://atlas.hashicorp.com/hashicorp/precise32”] 错误:SSL证书问题:无法获取本地颁发者证书 更多详情:http://curl.haxx.se/docs/sslcerts.html

curl默认使用“捆绑”执行SSL证书验证  证书颁发机构(CA)公钥(CA证书)。如果是默认值  捆绑文件不够用,您可以指定备用文件  使用--cacert选项。 如果此HTTPS服务器使用由CA表示的CA签名的证书  捆绑,证书验证可能由于a而失败  证书问题(可能已过期,或名称可能已过期)  与URL中的域名不匹配)。 如果您想关闭curl对证书的验证,请使用  -k(或--insecure)选项。

如何解决此错误?

4 个答案:

答案 0 :(得分:16)

如果您遇到SSL问题,可以尝试使用--insecure选项

添加该框
vagrant box add --insecure hashicorp/precise32 hashicorp/precise32
  

- insecure 如果存在,如果URL是HTTPS URL,则不会验证SSL证书

如果您有一些未完成的转移

,则可能需要清除~/.vagrant.d/tmp/文件夹

您也可以下载ssl证书并直接使用它来绕过错误

$ vagrant box add --cacert <certificate> box_name

答案 1 :(得分:11)

您可以在Vagrantfile

中添加它
import java.util.Scanner;
import static java.lang.System.out;


public class wordsArray {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        System.out.println("Please enter the details of your order");
        String myList = scan.nextLine();
    }

        myList[0] = "apple";
        myList[1] = "spinach";
        myList[2] = "dog";
        myList[3] = "fish";
        myList[4] = "goat";

        //Print all the array elements
        for (int i = 0; i < myList.length; i++) {
            System.out.println(myList[i] + " ");
       }


    }

答案 2 :(得分:6)

由于长期禁用SSL验证是一种可怕的做法,您可以通过将证书添加到嵌入式Ruby和curl的信任链中来纠正证书问题(痛苦但可能自动化,{{3} })或更好地使用添加到较新的Vagrant版本的备用CA路径? config.vm.box_download_ca_cert似乎是新设置。

手动方式:

The steps are as follows:

Step 1: Obtain the correct trust certificate
Step 2: Locate RubyGems certificate directory in your installation
Step 3: Copy correct trust certificate
Step 4: Profit


Step 1: Obtain the correct trust certificate

We need to download the correct trust certificate, YourCompanyRootCA.pem.
This can probably be obtained from your IT department or by exporting the certificate from your web browser or certificate store (and possibly converting to .pem using OpenSSL).

IMPORTANT: File must have .pem as extension. Browsers like Chrome will try to save it as plain text file. Ensure you change the filename to end with .pem after you have downloaded it.

Step 2: Locate Ruby certificate directory in your installation

In order for us copy this file, we need to know where to put it.

Depending on where you installed Ruby (or Vagrant has embedded it), the directory will be different.

Take for example the default installation of Ruby 2.1.5, placed in C:\Ruby21
Or the Vagrant default of C:\HashiCorp\Vagrant\embedded (or /opt on Linux)
Search for `cacert.pem` or any `*.pem` in those directories.

Step 3: Copy new trust certificate

Now, locate ssl_certs directory (Ruby) and copy the .pem file we obtained from previous step inside. 

It will be listed with other files like AddTrustExternalCARoot.pem.

If you are updating the Vagrant cacert.pem, make a backup copy, then append the entire contents of your new .pem file to the end of the cacert.pem. This should eliminate the warnings from Vagrant's ruby/curl.

答案 3 :(得分:0)

dragon788 回答的一些有用的附录

  1. 使用 OpenSSL 将 cer/crt 文件转换为 pem 文件。
  2. OpenSSL 可以位于 Windows 机器上的以下目录中 C:\Program Files\Git\usr\bin\openssl.exe
  3. 从证书管理器导出 cer/crt 文件时使用 base64 编码