问题
I've tried the following:
Setting mtu to 1400
Downgrading vagrant to 1.8.7 and VirtualBox to 5.1.38
Turn off firewall on host (osx) and guest (Ubuntu)
Turn off iptables in guest os
Ping works, but anything that requires ssl handshake will fail including curl and file_get_contents in php times out
Examples:
vagrant@scotchbox:~$ openssl s_client -connect www.google.com:443 -prexit
CONNECTED(00000003)
But using 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
It just hangs at this point.
PHP also has issues establishing handshakes:
Warning: file_get_contents(): SSL: Handshake timed out
回答1:
I stumbled at the same problem yesterday. I am now working back a HTTPS proxy with its own certificate. The host laptops are configured with this certificate but the VirtualBox guests are not. And this is valid for all guests. The solution is simple:
- Find and export the proxy's certificate in your HOST browser. I use Firefox and this is really simple
- Transfer the certificate file to the guest
- Run: sudo cp /etc/pki/ca-trust/source/anchors/
- And finally run: sudo update-ca-trust.
(I don't know the commands if you are running a Windows guest.)
来源:https://stackoverflow.com/questions/51603141/curl-works-outside-vm-but-not-inside