Curl在vm外部工作,但不在内部

时间:2018-07-30 22:32:07

标签: ssl vagrant virtualbox

我尝试了以下操作:

将mtu设置为1400

将vagrant降级为1.8.7,将VirtualBox降级为5.1.38

关闭主机(osx)和来宾(Ubuntu)上的防火墙

关闭来宾操作系统中的iptables

Ping有效,但是任何需要ssl握手的操作都将失败,包括php中的curl和file_get_contents超时

示例:

vagrant@scotchbox:~$ openssl s_client -connect www.google.com:443 -prexit
CONNECTED(00000003)

但是使用curl:

vagrant@scotchbox:~$ curl -iv https://www.google.com
* Rebuilt URL to: https://www.google.com/
*   Trying 216.58.194.36...
* Connected to www.google.com (216.58.194.36) port 443 (#0)
* found 173 certificates in /etc/ssl/certs/ca-certificates.crt
* found 694 certificates in /etc/ssl/certs
* ALPN, offering http/1.1

它现在就挂了。

PHP在建立握手方面也存在问题:

Warning: file_get_contents(): SSL: Handshake timed out

1 个答案:

答案 0 :(得分:1)

昨天我偶然发现了同样的问题。我现在正在使用自己的证书来回退HTTPS代理。主机笔记本电脑已配置了此证书,但VirtualBox guest虚拟机未配置。这对所有客人均有效。解决方案很简单:

  1. 在您的HOST浏览器中查找并导出代理的证书。我使用Firefox,这真的很简单
  2. 将证书文件传输给来宾
  3. 运行:sudo cp / etc / pki / ca-trust / source / anchors /
  4. 最后运行:sudo update-ca-trust。

(如果您正在运行Windows guest虚拟机,我不知道这些命令。)