jenssegers / php-proxy

A PHP proxy script with https and post support
https://jenssegers.com
933 stars 266 forks source link

Trust self signed https certificate #38

Closed stefanheimann closed 6 years ago

stefanheimann commented 8 years ago

Hello,

I'm trying to create a Proxy for an API which runs on a development computer. I'm facing the problem that I don't know how to tell the proxy to accept a self-signed SSL certificate.

This is the error I get: Fatal error: Uncaught exception 'GuzzleHttp\Ring\Exception\RingException' with message 'cURL error 60: See http://curl.haxx.se/libcurl/c/libcurl-errors.html' in /work/php_proxy/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php on line 51

here's my index.php:

use Proxy\Adapter\Guzzle\GuzzleAdapter;
use Proxy\Proxy;
use Symfony\Component\HttpFoundation\Request;

require '../vendor/autoload.php';

// Create a Symfony request based on the current browser request.
$request = Request::createFromGlobals();
// Create a guzzle client
$guzzle = new GuzzleHttp\Client;
$guzzle->setDefaultOption('verify', false);

// Create the proxy instance
$proxy = new Proxy(new GuzzleAdapter($guzzle));
// Forward the request and get the response.
$response = $proxy->forward($request)->to(urldecode($request->query->get('url')));

// Output response to the browser.
$response->send();

As stated in the guzzle docs, there's an option to trust self-signed certificates, but I dont know where to implement it. I tried it with the line

$guzzle->setDefaultOption('verify', false);

but it had no effect.

I'm using php-proxy v2.2.1, guzzle 5.0.

razbakov commented 6 years ago

Is there a solution for v2.x or it is only possible with v3.x?