在 Zend_HTTP_Client 中跳过 SSL 检查
我正在使用 Zend_HTTP_Client 向服务器发送 HTTP 请求并获取响应。我向其发送请求的服务器是 HTTPS Web 服务器。目前,一个往返请求大约需要 10-12 秒。据我了解,开销可能是由于请求所在的 Web 服务器处理速度缓慢所致。
是否可以像我们在 CURL 中那样跳过 SSL 证书检查以加快性能?如果可以的话,这些参数该如何设置呢?
我有以下代码:
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;
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;
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我只需要在处理遗留代码库时解决这个问题,并且能够像这样解决这个问题:
您可以与
verify_peer_name
一起设置的所有其他 SSL 选项是 在 PHP 手册中列出。I just had to address this while working on a legacy codebase, and I was able to work around the problem like this:
All the other SSL options you can set along with
verify_peer_name
are listed in the PHP manual.如果您确信
SSL
是问题所在,那么您可以将Zend_Http_Client
配置为使用curl
,然后传入适当的curl选项。
http://framework.zend.com/manual/en/zend .http.client.adapters.html
我实际上建议使用
curl
适配器,因为curl
几乎拥有您需要的所有选项,并且 < em>Zend 确实提供了一个非常好的包装器。If you're confident
SSL
is the issue, then you can configureZend_Http_Client
to usecurl
, and then pass in the appropriatecurl
options.http://framework.zend.com/manual/en/zend.http.client.adapters.html
I actually recommend using the
curl
adapter, just becausecurl
has pretty much every option you'll ever need, and Zend does provide a really nice wrapper.