使用PHP,Zend和openssl对PDF进行数字签名
发布时间:2020-12-13 13:20:12 所属栏目:PHP教程 来源:网络整理
导读:我正在尝试使用 PHP,openssl和Zend框架(用于pdf redering / handling)构建一个简单的PDF文档签名例程. 我发现this,但它根本不起作用,Zend无法打开任何pdf,甚至Zend自己的测试pdf和Zend也不会报告原因,只是它’不能’. 我很确定我能够有效地创建密钥/证书,因
我正在尝试使用
PHP,openssl和Zend框架(用于pdf redering / handling)构建一个简单的PDF文档签名例程.
我发现this,但它根本不起作用,Zend无法打开任何pdf,甚至Zend自己的测试pdf和Zend也不会报告原因,只是它’不能’. 我很确定我能够有效地创建密钥/证书,因为这有很好的文档,但有没有一种可靠的方法将生成的证书附加到PDF,因为上面的Zend扩展建议曾经这样做过? function DigiSignPDF ($pdf_sign_request) { if (get_magic_quotes_gpc()) { $new_pdf = stripslashes($pdf_sign_request['raw_pdf']); } else { $new_pdf = $pdf_sign_request['raw_pdf']; } $test_pdf = stripslashes(file_get_contents('path/Some.pdf')); $test_pdf2 = ('path/Some.pdf'); $pdf = Zend_Pdf::load($new_pdf2); //below is the signing code,from another library,it works as long as Zend_Pdf works $certificate = file_get_contents('path/certificate.p12'); $certificatePassword = 'test123'; if (empty($certificate)) { throw new Zend_Pdf_Exception('Cannot retrieve/generate the certificate.'); } $pdf->attachDigitalCertificate($certificate,$certificatePassword); $eSig_pdf = $pdf->render(); file_put_contents('path/signed_pdf.pdf',$eSig_pdf); } 编辑,添加代码:以上只有在我使用’test_pdf2’作为Zend_Pdf的输入时才有效.它将证书识别为二进制而没有任何问题,但我需要能够传递PDF而无需将其写入磁盘.
TCPDF支持
signing的pdf文件.也许你在源代码中找到了一些有用的东西.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- php – jQuery Mobile:如何正确提交表单数据
- PHP使用mysql_fetch_object从查询结果中获取对象集的方法
- php – 替换模式中的所有实例
- 浅谈php扩展imagick
- php – Bigcommmere Api使用图像链接创建产品
- PHP下获取上个月、下个月、本月的日期(strtotime,date)
- php实现mysql同步的实现方法
- 【Leetcode】Count Numbers with Unique Digits
- javaMail异常 NoClassDefFoundError: com/sun/mail/util/Li
- php – wp_rewrite在WordPress插件