setasign\SetaPDF2\Signer\Signature\Module

OpenSsl A signature module which uses the PHP builtin openssl functions.

File: /SetaPDF v2/Signer/Signature/Module/OpenSsl.php
Old class name (alias): \SetaPDF_Signer_Signature_Module_OpenSsl

This module make use of the function openssl_pkcs7_sign() to create the signature.

Class hierarchy

Implements

Summary

Properties

$_certificate

protected mixed OpenSsl::$_certificate

The certificate parameter

See

$_extraCertificates

protected string OpenSsl::$_extraCertificates

The path to a file containing bunch of extra certificates to include in the signature

$_fp

protected resource OpenSsl::$_fp

File pointer for the signed message

$_outPath

protected string OpenSsl::$_outPath

A temporary path of the signed message

$_privateKey

protected mixed OpenSsl::$_privateKey

The private key parameter

See

Methods

__construct()

public OpenSsl::__construct (
void
)

The constructor.

Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

_cleanUp()

protected OpenSsl::_cleanUp (
void
): void

Close file handles and remove temporary files if needed.

createSignature()

Create the signature.

This method creates a digital signature for the file available in $tmpPath and returns it in binary format.

Parameters
$tmpPath : \SetaPDF_Core_Reader_FilePath
 
Exceptions

Throws \setasign\SetaPDF2\Signer\Exception

Throws \InvalidArgumentException if the $tmpPath isn't readable

getCertificate()

public OpenSsl::getCertificate (
void
): mixed

Get the certificate parameter.

getExtraCertificates()

public OpenSsl::getExtraCertificates (
void
): string

Get the extra certificate parameter.

getPrivateKey()

public OpenSsl::getPrivateKey (
void
): mixed

Get the private key parameter

setCertificate()

public OpenSsl::setCertificate (
mixed $certificate
): void

Set the certificate parameter.

This module make use of the build in openssl functions. So the certificate parameter has to be passed as defined here: http://php.net/openssl.certparams.

Some examples:

$module->setCertificate(file_get_contents('path/to/certificate.pem'));
// or
$module->setCertificate('file://path/to/certificate.pem');

Notice the "file://" prefix if you need to pass the certificate path instead of its content.

Parameters
$certificate : mixed
 

setExtraCertificates()

public OpenSsl::setExtraCertificates (
string $extraCertificates
): void

Set the extra certificate parameter.

This parameter specifies the name of a file containing a bunch of extra certificates to include in the signature which can for example be used to help the recipient to verify the certificate that you used.

If the certificates are saved in separate files, you will need to assemble them in one single file. Just copy them with a text editor one after another.

Parameters
$extraCertificates : string
 

setPrivateKey()

public OpenSsl::setPrivateKey (
mixed $privateKey
): void

Set the private key parameter.

This module make use of the build in openssl functions. So the private key parameter has to be passed as defined here: http://php.net/openssl.certparams.

Parameters
$privateKey : mixed