gpt4 book ai didi

php - 警告 : openssl_pkcs7_sign(): error getting private key on Linux server

转载 作者:太空宇宙 更新时间:2023-11-03 12:56:51 27 4
gpt4 key购买 nike

也许这是一个重复的问题并在 this 中提出或 this但这个问题似乎很具体。

我想连接到使用 ssl 证书的银行互联网支付系统,但我遇到了这个错误:

Warning: openssl_pkcs7_sign(): error getting private key in /home/zarsamco/public_html/eghtesad/ipg/enpayment.php on line 52

这是我的代码中使用证书文件的部分(在本地 wamp 上):

openssl_pkcs7_sign(realpath("msg.txt"), realpath("signed.txt"), "file://D:/wamp/www/zarsam/eghtesad/certs/ZarsamHonar.pem",
array ("file://D:/wamp/www/zarsam/eghtesad/certs/ZarsamHonar.pem", "secretPass"),
array (), PKCS7_NOSIGS
);

它在本地(窗口 8)的 wamp 中工作正常,因为 ZarsamHonar.pem 的地址是绝对的。但是这段代码在远程服务器(Linux)上不起作用,因为我认为这种地址方式特别适用于 Windows。

我尝试了很多在网上找到的寻址方法和链接的 SO 问题。
例如我试试这段代码(enpayment.php 页面):

$prepend = "file://";
openssl_pkcs7_sign(realpath(dirname(__FILE__)) . "../msg.txt",
realpath(dirname(__FILE__)) . "../signed.txt",
$prepend . realpath(dirname(__FILE__)) ."/certs/ZarsamHonar.pem",
array($prepend . realpath(dirname(__FILE__)) ."/certs/ZarsamHonar.pem", "secretPass"),array(), PKCS7_NOSIGS);

但是也没有成功。

这是 ZarsamHonar.pem、msg.txt 和 signed.txt 文件的相关文件结构和位置的屏幕截图:

enter image description here

谁能帮帮我?

最佳答案

经过数小时的搜索并尝试不同的方法和指导 @Sjon,当然还根据 this user Comment在 php.net 上我找到了解决方案。

最后的代码是:

openssl_pkcs7_sign(realpath("msg.txt"), "signed.txt",
'file://'.realpath('/home/zarsamco/public_html/eghtesad/certs/zarsamhonar.pem'),
array ('file://'.realpath('/home/zarsamco/public_html/eghtesad/certs/zarsamhonar.pem'), "secretPass"),
array (), PKCS7_NOSIGS
);

第一个参数必须使用realpath函数,第二个参数不要使用。
因为它还不存在。并且对于第三个和第四个参数的寻址必须使用绝对路径以及 file:// 前缀。

关于php - 警告 : openssl_pkcs7_sign(): error getting private key on Linux server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32805518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com