警告:openssl_pkcs7_sign():在 Linux 服务器上获取私钥时出错 [英] Warning: openssl_pkcs7_sign(): error getting private key on Linux server
问题描述
也许这是一个重复的问题,并在
有人可以帮我吗?
经过数小时的搜索并尝试不同的方法和指导 @Sjon 当然根据 此用户评论 在 php.net 我找到了解决方案.
最后的代码是:
openssl_pkcs7_sign(realpath("msg.txt"), "signed.txt",'file://'.realpath('/home/zarsamco/public_html/eghtesad/certs/zarsamhonar.pem'),数组 ('file://'.realpath('/home/zarsamco/public_html/eghtesad/certs/zarsamhonar.pem'), "secretPass"),数组(),PKCS7_NOSIGS);
在第一个参数中必须使用 realpath 函数,但不要用于第二个.
因为它还不存在.并且为了寻址第三个和第四个参数必须使用绝对路径和 file:// 前缀.
Maybe this is a duplicate question and asked in this or this but this problem seems specific.
I want to connect to a bank internet payment system that uses ssl certificates but I face this error :
Warning: openssl_pkcs7_sign(): error getting private key in /home/zarsamco/public_html/eghtesad/ipg/enpayment.php on line 52
and this is the part of my code that uses certificate file (on wamp local):
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
);
it works fine in wamp on local (window 8) because the address of ZarsamHonar.pem is absolute. However this code does not work on remote server(Linux) because i think that this way of addresses is particular for windows.
I tried many Addressing methods found online and the linked SO questions.
for example I try this code (enpayment.php page):
$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);
But it did not work out either.
this is a screenshot of related files structure and location of ZarsamHonar.pem , msg.txt and signed.txt files:
can any one help me?
after hours of search and try different method and guidance @Sjon and of course according this user Comment on php.net I found the Solution.
the finally code is :
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
);
in the first parameter must use realpath function but do not use for second one.
because it does not exist yet. and for addressing third and forth parameter must use absolute path along with file:// prefix.
这篇关于警告:openssl_pkcs7_sign():在 Linux 服务器上获取私钥时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!