Download the PHP package setasign/setapdf-signer-addon-pkcs11 without Composer

On this page you can find all versions of the php package setasign/setapdf-signer-addon-pkcs11. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package setapdf-signer-addon-pkcs11

SetaPDF-Signer component module for PKCS11

This package offers a module for the SetaPDF-Signer component that allows you to use keys stored on a PKCS11 compatible device (e.g. HSM, USB Token) to digital sign PDF documents in pure PHP.

Requirements

This module requires the PKCS11 PHP extension to be installed.

You also need to provide the path to the PKCS11 module of your device.

The package is developed and tested on PHP >= 7.4. Requirements of the SetaPDF-Signer component can be found here.

Installation

Add following to your composer.json:

{
    "require": {
        "setasign/setapdf-signer-addon-pkcs11": "^1.0"
    },
    "repositories": [
        {
            "type": "composer",
            "url": "https://www.setasign.com/downloads/"
        }
    ]
}

and execute composer update. You need to define the repository to evaluate the dependency to the SetaPDF-Signer component (see here for more details).

Usage

All classes in this package are located in the namespace setasign\SetaPDF\Signer\Module\Pkcs11.

The Module class

This is the main signature module which can be used with the SetaPDF-Signer component. Internally it holds an own instance of the PAdES signature module and offers all relevant proxy methods.

The only arguments you need to pass to the Module instance is a \Pkcs11\Key instance of the private key and the related X509 certificate.

The default padding schema for signatures using RSA keys is RSASSA-PKCS1-v1_5. To use RSASSA-PSS just call $module->setPssPadding();.

A simple complete signature process would look like this:

$pin = '123456';

$modulePath = '/usr/lib/softhsm/libsofthsm2.so';
$pkcs11 = new Pkcs11\Module($modulePath);

$slotList = $pkcs11->getSlotList();
$slotId = $slotList[0];

$session = $pkcs11->openSession($slotId, Pkcs11\CKF_RW_SESSION);
$session->login(Pkcs11\CKU_USER, $pin);

$skey = $session->findObjects([
    Pkcs11\CKA_PRIVATE => true,
    Pkcs11\CKA_LABEL => "SetaPDF-Demo"
])[0];

$module = new setasign\SetaPDF\Signer\Module\Pkcs11\Module($skey);
$module->setCertificate('path/to/setapdf.pem');
$module->setPssPadding();
$module->setDigest(SetaPDF_Signer_Digest::SHA_512);

$fileToSign = 'path/to/Laboratory-Report.pdf';

// create a writer instance
$writer = new SetaPDF_Core_Writer_Http('signed.pdf');
// create the document instance
$document = SetaPDF_Core_Document::loadByFilename($fileToSign, $writer);

// create the signer instance
$signer = new SetaPDF_Signer($document);
$signer->sign($module);

$session->logout();

Testing

For testing purpose we used SoftHSM2 and imported existing test certificates and keys into it using following command:

softhsm2-util --import <PATH-TO-CERTIFICATE> --token "<THE-TOKEN-NAME>" --label "<THE-LABEL>" --id <UNIQUE-ID-IN-HEX-NOTATION>

CSR generation and key attestation is not part of this add-on.


All versions of setapdf-signer-addon-pkcs11 with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
setasign/setapdf-signer Version ^2.44
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package setasign/setapdf-signer-addon-pkcs11 contains the following files

Loading the files please wait ....