7

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;
1
  • Your guessing what the performance problem might be? Why not find out for sure? Commented Jul 30, 2010 at 0:17

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

Comments

0

I just had to address this while working on a legacy codebase, and I was able to work around the problem like this:

        $client = new Zend_Http_Client();

        // Disable SSL hostname verification.
        $client->getAdapter()->setStreamContext([
            'ssl' => [
                'verify_peer_name' => false,
            ]
        ]);

All the other SSL options you can set along with verify_peer_name are listed in the PHP manual.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.