Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Skip SSL Check in Zend_HTTP_Client

I am using Zend_HTTP_Client to send HTTP requests to a server and get response back. The server which I am sending the requests to is an HTTPS web server. Currently, one round trip request takes around 10-12 seconds. I understand the overhead might be because of the slow processing of the web server to which the requests go.

Is it possible to skip SSL certificate checks like we do in CURL to speed up the performance? If so, how to set those parameters?

I have the following code:

    try
    {
        $desturl ="https://1.2.3.4/api";

        // Instantiate our client object
        $http = new Zend_Http_Client();

        // Set the URI to a POST data processor
        $http->setUri($desturl);

        // Set the POST Data
        $http->setRawData($postdata);

        //Set Config
        $http->setConfig(array('persistent'=>true));

        // Make the HTTP POST request and save the HTTP response
        $httpResponse = $http->request('POST');
    }
    catch (Zend_Exception $e)
    {
        $httpResponse = "";
    }

    if($httpResponse!="")
    {
        $httpResponse = $httpResponse->getBody();
    }

    //Return the body of HTTTP Response
    return  $httpResponse;
like image 699
Jake Avatar asked Jul 30 '10 00:07

Jake


1 Answers

If you're confident SSL is the issue, then you can configure Zend_Http_Client to use curl, and then pass in the appropriate curl options.

http://framework.zend.com/manual/en/zend.http.client.adapters.html

$config = array(  
    'adapter'   => 'Zend_Http_Client_Adapter_Curl',  
    'curloptions' => array(CURLOPT_SSL_VERIFYPEER => false),  
); 

$client = new Zend_Http_Client($uri, $config);

I actually recommend using the curl adapter, just because curl has pretty much every option you'll ever need, and Zend does provide a really nice wrapper.

like image 183
Chris Henry Avatar answered Nov 11 '22 17:11

Chris Henry