2012-03-20 74 views
1

我在使用CURL向服务器发送请求的网站上有一个curl脚本。另一方面,我使用wkhtmltopdf生成与收到的HTML的PDF,这工作正常,当HTT未在网站上启用,但只要我启用HTTPS的PDF遗传抛出错误。https/ssl在通过curl发送HTML时导致问题

MY卷曲脚本

$url = Yii::app()->params['pdfUrl']; //Equals http://xxx.xx.xxx.xxx/server/?r=pdf/generatePdf 

      $body = array(
       "client_url"=>Yii::app()->params['pdfClientURL'], 
       "client_id"=>Yii::app()->params['pdfClientID'], 
       "title"=>urlencode($title), 
       "content"=>urlencode(($content)) 

      ); 
      foreach($body as $key=>$value) { $body_str .= $key.'='.$value.'&'; } 
       rtrim($body_str,'&'); 

      curl_setopt ($c, CURLOPT_POST, true); 
      curl_setopt ($c, CURLOPT_POSTFIELDS, $body_str); 

      curl_setopt ($c, CURLOPT_RETURNTRANSFER, true); 
      $pdf = curl_exec ($c); 

      curl_close ($c); 
      header("Content-Type: application/pdf"); 
      header("Cache-Control: no-cache"); 
      header("Accept-Ranges: none"); 
      header("Content-Disposition: attachment; filename=".str_replace(' ', '_', $title).".pdf"); 
      echo $pdf; 
      Yii::app()->end(); 

那会是什么,由于https是造成?

错误,我得到WKHTML2PDF

WKPDF system error: <pre>Loading pages (1/6) 
[> ] 0% 
[======> ] 10% 
[===========> ] 19% 
QSslSocket: cannot call unresolved function SSLv23_client_method 
QSslSocket: cannot call unresolved function SSL_CTX_new 
QSslSocket: cannot call unresolved function SSL_library_init 
QSslSocket: cannot call unresolved function ERR_get_error 
QPixmap: Cannot create a QPixmap when no GUI is being used 
QPixmap: Cannot create a QPixmap when no GUI is being used 
QPixmap: Cannot create a QPixmap when no GUI is being used 
QPixmap: Cannot create a QPixmap when no GUI is being used 
QPixmap: Cannot create a QPixmap when no GUI is being used 
QPixmap: Cannot create a QPixmap when no GUI is being used 
[============================================================] 100% 
Counting pages (2/6) 
[============================================================] Object 1 of 1 
Resolving links (4/6) 
[============================================================] Object 1 of 1 
Loading headers and footers (5/6) 
Printing pages (6/6) 
[> ] Preparing 
[============================================================] Page 1 of 1 
Done 
</pre> 
+0

你能给我们提供错误吗? – 2012-03-20 20:52:38

+0

@Keeyai - 已更新的问题 – Roland 2012-03-20 20:56:24

+0

看起来wkhtml2pdf在ssl下执行有问题,但我不确定它为什么在ssl中做任何事情。我的第一个猜测是,既然你使用https请求,wkhtml2pdf也试图使用ssl来获取图像。我之前没有在ssl下使用过wkhtml2pdf,你可以手动关闭它,或者可以使用http或甚至本地显式加载图像?另一种方法是解决实际问题,并找出为什么wkhtml2pdf与SSL失败 - 你自己编译它? – 2012-03-20 21:04:25

回答

5

好吧,发现问题@Keeyai指出我到正确的方向后。我设法找到了这篇文章,http://code.google.com/p/wkhtmltopdf/issues/detail?id=17&q=ssl,并在安装了wkhtml2pdf并解决问题的服务器上安装了openssl-devel。由于问题是由使用https链接的图像引起的

yum install openssl-devel是否有窍门

+1

解决问题而不是症状! – 2012-03-20 22:06:00

0

看一看the curl_setopts page

像CURLOPT_SSL_VERIFYPEER = false的事情可能会有所帮助。

必须通过该页面在与SSL的各种选项一看 - 相信你会找到答案有...

+0

试过这个,它不能正常工作 – Roland 2012-03-20 21:13:41