<small id='Wkb9x'></small><noframes id='Wkb9x'>

    <legend id='Wkb9x'><style id='Wkb9x'><dir id='Wkb9x'><q id='Wkb9x'></q></dir></style></legend>
    <i id='Wkb9x'><tr id='Wkb9x'><dt id='Wkb9x'><q id='Wkb9x'><span id='Wkb9x'><b id='Wkb9x'><form id='Wkb9x'><ins id='Wkb9x'></ins><ul id='Wkb9x'></ul><sub id='Wkb9x'></sub></form><legend id='Wkb9x'></legend><bdo id='Wkb9x'><pre id='Wkb9x'><center id='Wkb9x'></center></pre></bdo></b><th id='Wkb9x'></th></span></q></dt></tr></i><div id='Wkb9x'><tfoot id='Wkb9x'></tfoot><dl id='Wkb9x'><fieldset id='Wkb9x'></fieldset></dl></div>

    1. <tfoot id='Wkb9x'></tfoot>

      • <bdo id='Wkb9x'></bdo><ul id='Wkb9x'></ul>
    2. 使用旧证书调用 HTTPS 页面时的 cURL 超时

      cURL timeout when calling HTTPS page with old certs(使用旧证书调用 HTTPS 页面时的 cURL 超时)
        <bdo id='zzI1X'></bdo><ul id='zzI1X'></ul>

            <tbody id='zzI1X'></tbody>

          1. <i id='zzI1X'><tr id='zzI1X'><dt id='zzI1X'><q id='zzI1X'><span id='zzI1X'><b id='zzI1X'><form id='zzI1X'><ins id='zzI1X'></ins><ul id='zzI1X'></ul><sub id='zzI1X'></sub></form><legend id='zzI1X'></legend><bdo id='zzI1X'><pre id='zzI1X'><center id='zzI1X'></center></pre></bdo></b><th id='zzI1X'></th></span></q></dt></tr></i><div id='zzI1X'><tfoot id='zzI1X'></tfoot><dl id='zzI1X'><fieldset id='zzI1X'></fieldset></dl></div>
              <tfoot id='zzI1X'></tfoot>
                <legend id='zzI1X'><style id='zzI1X'><dir id='zzI1X'><q id='zzI1X'></q></dir></style></legend>

                <small id='zzI1X'></small><noframes id='zzI1X'>

                本文介绍了使用旧证书调用 HTTPS 页面时的 cURL 超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在尝试使用 PHP 和 cURL (libcurl) 从我所在机构的数据服务获取 XML.开发正在我的本地机器上完成.它是在 PHP 中作为 Drupal 和 Transformations 模块的一部分进行评估的代码.

                I am trying to get the XML from a Data Service at my institution using PHP and cURL (libcurl). The development is being done on my local machine. It is code that is eval'd in PHP as part of Drupal and the Transformations module.

                它具有 SSL 支持,如运行所示:

                It has SSL support as shown from running:

                $curl-config --features (来自 libcurl 文档)

                SSL
                IPv6

                NTLM

                SSL
                IPv6
                libz
                NTLM

                正在执行的 PHP 代码:

                The PHP code being executed:

                /**
                 * Get a web file (HTML, XHTML, XML, image, etc.) from a URL.  Return an
                 * array containing the HTTP server response header fields and content.
                 * FROM: http://bit.ly/lNIlOu
                 */
                function get_web_page( $url )
                {
                  $agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30';
                  //$agent = 'spider';
                
                  $options = array(
                    CURLOPT_RETURNTRANSFER => true,     // return web page if successful
                    CURLOPT_HEADER         => false,    // don't return headers
                    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
                    CURLOPT_ENCODING       => "",       // handle all encodings
                    CURLOPT_USERAGENT      => $agent, // who am i
                    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
                    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
                    CURLOPT_TIMEOUT        => 120,      // timeout on response
                    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
                    CURLOPT_SSL_VERIFYPEER => false,    // Disabled SSL Cert checks
                    CURLOPT_SSL_VERIFYHOST => false,    // Disable host checks ?
                  );
                
                  $ch      = curl_init( $url );
                  curl_setopt_array( $ch, $options );
                  $content = curl_exec( $ch );
                  $err     = curl_errno( $ch );
                  $errmsg  = curl_error( $ch );
                  $header  = curl_getinfo( $ch );
                  curl_close( $ch );
                
                  $header['errno']   = $err;
                  $header['errmsg']  = $errmsg;
                  $header['content'] = $content;
                  return $header;
                }
                
                $url = 'https://ws.admin.washington.edu/student/v4/public/section.xml?year=2011&quarter=autumn&curriculum_abbreviation=BIOL&course_number=&id=&search_by=Instructor';
                $result = get_web_page($url);
                
                echo '<pre>CURL result:<br/>';
                var_dump($result);
                echo '</pre>';
                

                倾销 $ch 的精简版:

                A slimmed down version of dumping $ch:

                array(24) {
                  ["url"]=>
                  string(155) "https://ws.admin.washington.edu/student/v4/public/section.xml?year=2011&quarter=autumn&curriculum_abbreviation=BIOL&course_number=&id=&search_by=Instructor"
                  ["content_type"]=>
                  NULL
                  ["http_code"]=>
                  int(0)
                  ["header_size"]=>
                  int(0)
                  ["request_size"]=>
                  int(237)
                  ...
                  ["ssl_verify_result"]=>
                  int(20)
                  ["redirect_count"]=>
                  int(0)
                  ["total_time"]=>
                  float(120.41427)
                  ...
                  ["connect_time"]=>
                  float(0.11626)
                  ...
                  ["certinfo"]=>
                  array(0) {
                  }
                  ["errno"]=>
                  int(28)
                  ["errmsg"]=>
                  string(67) "Operation timed out after 120000 milliseconds with 0 bytes received"
                  ["content"]=>
                  bool(false)
                }
                

                当我自己访问该网站时,它只会加载.我什至将代理签名设置为与我自己的完全相同.

                When I visit the site myself it simply loads. I even set the agent signature to be the exact same as my own.

                任何帮助将不胜感激.

                推荐答案

                对于我来说添加 curl_setopt($ch, CURLOPT_SSLVERSION, 3); 神奇地解决了这个问题!

                For me adding curl_setopt($ch, CURLOPT_SSLVERSION, 3); magically solved the issue!

                这篇关于使用旧证书调用 HTTPS 页面时的 cURL 超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                How do I pass parameters into a PHP script through a webpage?(如何通过网页将参数传递给 PHP 脚本?)
                PHP - include a php file and also send query parameters(PHP - 包含一个 php 文件并发送查询参数)
                Where can I read about conditionals done with quot;?quot; and quot;:quot; (colon)?(我在哪里可以阅读有关使用“?完成的条件的信息?和“:(冒号)?)
                Accessing arrays whitout quoting the key(在不引用键的情况下访问数组)
                What is the name for the quot;lt;lt;lt;quot; operator?(“lt;lt;lt;的名字是什么?操作员?)
                default as first option in switch statement?(默认为 switch 语句中的第一个选项?)
                <tfoot id='lUsO2'></tfoot>
                • <bdo id='lUsO2'></bdo><ul id='lUsO2'></ul>
                  <i id='lUsO2'><tr id='lUsO2'><dt id='lUsO2'><q id='lUsO2'><span id='lUsO2'><b id='lUsO2'><form id='lUsO2'><ins id='lUsO2'></ins><ul id='lUsO2'></ul><sub id='lUsO2'></sub></form><legend id='lUsO2'></legend><bdo id='lUsO2'><pre id='lUsO2'><center id='lUsO2'></center></pre></bdo></b><th id='lUsO2'></th></span></q></dt></tr></i><div id='lUsO2'><tfoot id='lUsO2'></tfoot><dl id='lUsO2'><fieldset id='lUsO2'></fieldset></dl></div>
                • <small id='lUsO2'></small><noframes id='lUsO2'>

                      <legend id='lUsO2'><style id='lUsO2'><dir id='lUsO2'><q id='lUsO2'></q></dir></style></legend>

                            <tbody id='lUsO2'></tbody>