Warning: openssl_pkcs7_sign(): error getting private key using WAMP

≡放荡痞女 提交于 2019-12-01 04:27:38

问题


I am trying to sign PDF using TCPDF, but I have got this error:

Warning: openssl_pkcs7_sign(): error getting private key in C:\wamp\www\tcpdf\tcpdf.php on line 7594.   

My PHP version is 5.5.12 and TCPDF 6.2.11. Windows 7.

Other examples run well but this fails. I have tried:

'file://'.( dirname(FILE)).'./path/to/file' and again $certificate = 'file://'.realpath('../tcpdf.crt'); 

but does not work for me.


回答1:


I think file:// is not correct. You fetch die real path with dirname(__FILE__) that should be enough. So i prefer:

$certificate = __DIR__'/../tcpdf.crt';

__DIR__ or dirname(FILE) is the path to the file you've in. To you can go back with /../../ to your file depends on your folder location for your certificate files.




回答2:


You need the 'file://' prefix and the realpath to file:

//in your case
$certificate = 'file://'.realpath('../tcpdf.crt');
// OR for other cases
$certificate = 'file://'.realpath('/tcpdf.crt');
// OR
$certificate = 'file://'.realpath('C:/tcpdf.crt');


来源:https://stackoverflow.com/questions/32083044/warning-openssl-pkcs7-sign-error-getting-private-key-using-wamp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!