Skip to content

Commit

Permalink
RM-3579.1
Browse files Browse the repository at this point in the history
  • Loading branch information
strey223 committed Oct 5, 2021
1 parent ae613de commit 1643fb3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions CryptoProCli.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ public static function verifyFileContent($fileContent)
*/
public static function verifyFileContentDetached($fileSignContent, $fileToBeSignedContent)
{
$fileSign = tempnam(sys_get_temp_dir(), 'cpc');
$fileToBeSigned = tempnam(sys_get_temp_dir(), 'ftbs');
$fileToBeSigned = tempnam(sys_get_temp_dir(), 'detach');
$fileSign .= $fileToBeSigned . '.sgn';
file_put_contents($fileSign, $fileSignContent);
file_put_contents($fileToBeSigned, $fileToBeSignedContent);
try {
Expand Down Expand Up @@ -171,14 +171,17 @@ public static function verifyFile($file)
*
* @param $fileSign
* @param $fileToBeSigned
* @param $fileDir
* @throws Cli
* @throws SignatureError
*/
public static function verifyFileDetached($fileSign, $fileToBeSigned)
public static function verifyFileDetached($fileSign, $fileToBeSigned, $fileDir)
{
//Пример cryptcp.exe -verify y:\text.txt -detached -nochain -f y:\signature.sig -dir y:\
$shellCommand = 'yes "n" 2> '.self::getDevNull() . ' | ' . escapeshellarg(self::$cryptcpExec) . ' -verify -verall ' . escapeshellarg($fileSign)
. ' -detached -f ' . escapeshellarg($fileToBeSigned);
$shellCommand = 'yes "n" 2> '.self::getDevNull() . ' | ' . escapeshellarg(self::$cryptcpExec) . ' -vsignf -dir '
. escapeshellarg($fileDir) . ' '
. escapeshellarg($fileSign)
. ' -f ' . escapeshellarg($fileToBeSigned);
$result = shell_exec($shellCommand);
if (strpos($result, "[ErrorCode: 0x00000000]") === false && strpos($result, "[ReturnCode: 0]") === false) {
preg_match('#\[ErrorCode: (.+)\]#', $result, $matches);
Expand Down

0 comments on commit 1643fb3

Please sign in to comment.