$cert = realpath('mycertandkey.crt'); $passphrase = 'Passphrase for the private key in $cert'; // your <customer name>:<key entity> $customerId = ""; } // options for the SoapClient instance $clientOptions = array('stream_context' => stream_context_create(array('ssl' => array('verify_peer' => true, 'cafile' => __DIR__ . '/ais-ca-ssl.crt', 'peer_name' => 'ais.swisscom.com'))), 'local_cert' => $cert, 'passphrase' => $passphrase); // create a re-usable array of filenames (in/out) $files = array(array('in' => 'files/tektown/Laboratory-Report.pdf', 'out' => 'output/tektown-signed.pdf'), array('in' => 'files/lenstown/Laboratory-Report.pdf', 'out' => 'output/lenstown-signed.pdf'), array('in' => 'files/etown/Laboratory-Report.pdf', 'out' => 'output/etown-signed.pdf'), array('in' => 'files/camtown/Laboratory-Report.pdf', 'out' => 'output/camtown-signed.pdf')); // create document instances by the filenames $documents = array(); foreach ($files as $file) { $documents[] = SetaPDF_Core_Document::loadByFilename($file['in'], new SetaPDF_Core_Writer_File($file['out'])); } // initiate a batch instance $batch = new SetaPDF_Signer_SwisscomAIS_Batch($customerId, $clientOptions); // let's add PADES revoke information to the resulting signatures $batch->setAddRevokeInformation('PADES'); // the signatures should include a timestamp, too $batch->setAddTimestamp(true); try { // sign the documents and add the revoke information to the DSS of the documents $batch->sign($documents, true, array(SetaPDF_Signer::PROP_LOCATION => $_SERVER['SERVER_NAME'], SetaPDF_Signer::PROP_REASON => 'Testing')); } catch (SetaPDF_Signer_SwisscomAIS_Exception $e) { echo 'Error in SwisscomAIS: ' . $e->getMessage() . ' with code ' . $e->getCode() . '<br />'; /* Get the AIS Error details */ echo "<pre>"; var_dump($e->getResultMajor()); var_dump($e->getResultMinor()); echo "</pre>"; die;
$cert = realpath('mycertandkey.crt'); $passphrase = 'Passphrase for the private key in $cert'; // your <customer name> $customerId = ""; } // options for the SoapClient instance $clientOptions = array('stream_context' => stream_context_create(array('ssl' => array('verify_peer' => true, 'cafile' => __DIR__ . '/ais-ca-ssl.crt', 'peer_name' => 'ais.swisscom.com'))), 'local_cert' => $cert, 'passphrase' => $passphrase); // create a re-usable array of filenames (in/out) $files = array(array('in' => 'files/tektown/Laboratory-Report.pdf', 'out' => 'output/tektown-timestamped.pdf'), array('in' => 'files/lenstown/Laboratory-Report.pdf', 'out' => 'output/lenstown-timestamped.pdf'), array('in' => 'files/etown/Laboratory-Report.pdf', 'out' => 'output/etown-timestamped.pdf'), array('in' => 'files/camtown/Laboratory-Report.pdf', 'out' => 'output/camtown-timestamped.pdf')); // create document instances by the filenames $documents = array(); foreach ($files as $file) { $documents[] = SetaPDF_Core_Document::loadByFilename($file['in'], new SetaPDF_Core_Writer_File($file['out'])); } // initiate a batch instance $batch = new SetaPDF_Signer_SwisscomAIS_Batch($customerId, $clientOptions); // let's add PADES revoke information to the resulting signatures $batch->setAddRevokeInformation('PADES'); try { // timestamp the documents and add the revoke information to the DSS of the documents $batch->timestamp($documents, true); } catch (SetaPDF_Signer_SwisscomAIS_Exception $e) { echo 'Error in SwisscomAIS: ' . $e->getMessage() . ' with code ' . $e->getCode() . '<br />'; /* Get the AIS Error details */ echo "<pre>"; var_dump($e->getResultMajor()); var_dump($e->getResultMinor()); echo "</pre>"; die; } // get access to the last result object
$approvalMsg = 'Sign Laboratory-Report.pdf as ' . $signerMail . '?'; $approvalMsg .= ' (#TRANSID#)'; // Add the unique transaction ID placeholder at the end // set the Mobile ID SerialNumber if needed (example: MIDCHEGU8GSH6K83) $approvalSn = ''; // options for the SoapClient instance $clientOptions = array('stream_context' => stream_context_create(array('ssl' => array('verify_peer' => true, 'cafile' => __DIR__ . '/ais-ca-ssl.crt', 'peer_name' => 'ais.swisscom.com'))), 'local_cert' => $cert, 'passphrase' => $passphrase); // create a re-usable array of filenames (in/out) $files = array(array('in' => 'files/tektown/Laboratory-Report.pdf', 'out' => 'output/tektown-signed-on-demand.pdf'), array('in' => 'files/lenstown/Laboratory-Report.pdf', 'out' => 'output/lenstown-signed-on-demand.pdf'), array('in' => 'files/etown/Laboratory-Report.pdf', 'out' => 'output/etown-signed-on-demand.pdf'), array('in' => 'files/camtown/Laboratory-Report.pdf', 'out' => 'output/camtown-signed-on-demand.pdf')); // create document instances by the filenames $documents = array(); foreach ($files as $file) { $documents[] = SetaPDF_Core_Document::loadByFilename($file['in'], new SetaPDF_Core_Writer_File($file['out'])); } // initiate a batch instance $batch = new SetaPDF_Signer_SwisscomAIS_Batch($customerId, $clientOptions); // let's add PADES revoke information to the resulting signatures $batch->setAddRevokeInformation('PADES'); // the signatures should include a timestamp, too $batch->setAddTimestamp(true); // set on-demand options $batch->setOnDemandOptions($signerDn); if ($approvalNo !== '') { $batch->setOnDemandOptions($signerDn, $approvalNo, $approvalMsg, $approvalLang, $approvalSn); } try { // sign the documents and add the revoke information to the DSS of the documents $batch->sign($documents, true); } catch (SetaPDF_Signer_SwisscomAIS_Exception $e) { echo 'Error in SwisscomAIS: ' . $e->getMessage() . ' with code ' . $e->getCode() . '<br />'; /* Get the AIS Error details */