2012-03-20 68 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