You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
738 B
PHP

<?php
namespace Cijber\OpenSSL\PKCS7;
use Cijber\OpenSSL;
use Cijber\OpenSSL\BIO;
use Cijber\OpenSSL\Stack\X509Stack;
use Cijber\OpenSSL\X509Store;
class Signed
{
use Helpers;
public function getCerts(): X509Stack
{
$stack = X509Stack::from($this->ffi, $this->data->cert, $this);
$stack->unmanaged();
return $stack;
}
public function verify(string $plain, int $flags, ?X509Store $x509Store = null)
{
if ($x509Store === null) {
$x509Store = OpenSSL::CAStore();
}
$buffer = BIO::buffer($plain);
$x = $this->ffi->PKCS7_verify($this->parent, null, $x509Store->getCData(), $buffer->getCData(), null, $flags);
return $x === 1;
}
}