https/ssl在通过curl发送HTML时引发问题


https/ssl causing issues when sending HTML over curl

我在一个网站上有一个curl脚本,它使用curl向服务器发出post请求。另一方面,我使用wkhtmltopdf用收到的HTML生成PDF,当网站上没有启用https时,这很好,但一旦我启用https,PDF生成就会出现错误。

我的卷曲脚本

$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> 

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

yum-install-openssl-devel完成了

查看curl_setopts页面。

CURLOPT_SSL_VERIFYPEER=false之类的东西可能会有所帮助。

浏览一下该页面中与ssl相关的各种选项,确保您能在那里找到答案。。。