OpenSSL S/MIME Module (CLI)

Table of Contents

  1. Description
    1. Public Methods
      1. Demo

        Description

        The SetaPDF_Signer_Signature_Module_OpenSslCli module uses the S/MIME utility of OpenSSL to create the signature. 

        It allows you e.g. to define a specifc digest algorithm.  

        The utility will be executed by an exec() call.

        Public Methods

        getCertificate()

        Get the path to the signing certificate.

        getDigest()

        Get the digest algorithm.

        getExtraCertificates()

        Get the path of the file with additional certificates.

        getOpenSslPath()

        Get the path to the openssl binary.

        getPrivateKey()

        Get the path to the private key file.

        getPrivateKeyPassword()

        Get the private key password source.

        setCertificate()

        Set the path to the signing certificate.

        setDigest()

        Set the digest algorithm to use when signing.

        setExtraCertificates()

        Set the path to a file with additional certificates which will be included in the signature.

        setOpenSslPath()

        Set the path to the openssl binary.

        setPrivateKey()

        Set the path to the private key file and password argument.

        setPrivateKeyPassword()

        Set the private key password source.

        Demo

        PHP
        <?php
        require_once('library/SetaPDF/Autoload.php');
        
        // create a writer
        $writer = new SetaPDF_Core_Writer_Http('simple.pdf', true);
        // create a new document instance
        $document = SetaPDF_Core_Document::loadByFilename(
            'files/pdfs/tektown/Laboratory-Report.pdf', $writer
        );
        
        // create a signer instance
        $signer = new SetaPDF_Signer($document);
        
        // set some signature properties
        $signer->setReason('Testing CMS module');
        $signer->setLocation('SetaPDF-Signer Manual');
        
        // create a signature module
        $module = new SetaPDF_Signer_Signature_Module_OpenSslCli();
        // load the certificate
        $certificate = 'files/certificates/setapdf-no-pw.pem';
        $module->setCertificate($certificate);
        $module->setPrivateKey($certificate, '' /* no password */);
        
        // sign the document and send the final document to the initial writer
        $signer->sign($module);