警告:openssl_pkcs7_sign():使用WAMP获取私钥错误



我正在尝试使用TCPDF签署PDF,但我得到了这个错误:

Warning: openssl_pkcs7_sign(): error getting private key in C:wampwwwtcpdftcpdf.php on line 7594.   

我的PHP版本是5.5.12,TCPDF是6.2.11。Windows 7。

其他例子运行良好,但这个失败了。我试过了:

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

我认为file://不正确。你用dirname(__FILE__)获取一个真实路径就足够了。所以我更喜欢:

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

__DIR__dirname(FILE)是您所在文件的路径。您是否可以使用/../../返回到您的文件取决于您的证书文件的文件夹位置。

您需要'file://'前缀和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');

最新更新