Skip to content

Commit d9519da

Browse files
committed
Update ltv-demo.php
- Add LTV only in the additional DSS update.
1 parent 9939d25 commit d9519da

File tree

1 file changed

+13
-31
lines changed

1 file changed

+13
-31
lines changed

examples/ltv-demo.php

Lines changed: 13 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -82,29 +82,8 @@
8282
$module->setCredentialId($credentialId);
8383
$module->setSignatureAlgorithmOid($algorithm);
8484
$module->setCertificate($certificate);
85-
86-
// now add this information to the CMS container
8785
$module->setExtraCertificates($certificates);
8886

89-
// create a collection of trusted certificats:
90-
$trustedCertificates = new Collection($certificates[count($certificates) - 1]);
91-
$trustedCertificates->add(PemHelper::extractFromFile($trustedCertificatesPath));
92-
// sadly not all CSC API implementations return the full chain (in our tests e.g. SSL.com), so we have to
93-
// add a trusted root on our own:
94-
foreach ($otherTrustedCertificatePaths as $otherTrustedCertificatePath) {
95-
$trustedCertificates->addFromFile($otherTrustedCertificatePath);
96-
}
97-
98-
// create a collector instance
99-
$collector = new Collector($trustedCertificates);
100-
$vriData = $collector->getByCertificate($certificate);
101-
foreach ($vriData->getOcspResponses() as $ocspResponse) {
102-
$module->addOcspResponse($ocspResponse);
103-
}
104-
foreach ($vriData->getCrls() as $crl) {
105-
$module->addCrl($crl);
106-
}
107-
10887
if ($credentialInfo['authMode'] === 'explicit' && !isset($_GET['otp']) && !isset($_GET['pin'])) {
10988
// you should check the OTP and/or PIN entry in $credentialInfo for how to setup authentication exactly
11089
echo 'Please enter OTP or PIN:';
@@ -128,8 +107,8 @@
128107

129108
// create the signer instance
130109
$signer = new Signer($document);
131-
// because of the timestamp and VRI data we need more space for the signature container
132-
$signer->setSignatureContentLength(40000);
110+
// because of the timestamp we need more space for the signature container
111+
$signer->setSignatureContentLength(20000);
133112

134113
// setup a timestamp module
135114
$tsModule = new Curl($timestampingUrl);
@@ -157,6 +136,14 @@
157136
// create a new instance
158137
$document = Document::loadByFilename($tmpWriter->getPath(), $writer);
159138

139+
// create a collection of trusted certificats:
140+
$trustedCertificates = new Collection($certificates[count($certificates) - 1]);
141+
$trustedCertificates->add(PemHelper::extractFromFile($trustedCertificatesPath));
142+
// sadly not all CSC API implementations return the full chain (in our tests e.g. SSL.com), so we have to
143+
// add a trusted root on our own:
144+
foreach ($otherTrustedCertificatePaths as $otherTrustedCertificatePath) {
145+
$trustedCertificates->addFromFile($otherTrustedCertificatePath);
146+
}
160147
// create a VRI collector instance
161148
$collector = new Collector($trustedCertificates);
162149
// Use IPv4 to bypass an issue at http://ocsp.ensuredca.com
@@ -165,19 +152,14 @@
165152
//]);
166153

167154
// get VRI for the timestamp signature
168-
$vriData = $collector->getByFieldName(
169-
$document,
170-
$signatureField->getQualifiedName(),
171-
Collector::SOURCE_OCSP_OR_CRL,
172-
null,
173-
null,
174-
$vriData // pass the previously gathered VRI data
175-
);
155+
$vriData = $collector->getByFieldName($document, $signatureField->getQualifiedName());
176156

177157
//$logger = $collector->getLogger();
158+
//echo "<pre>";
178159
//foreach ($logger->getLogs() as $log) {
179160
// echo str_repeat(' ', $log->getDepth() * 4) . $log . "\n";
180161
//}
162+
//echo "</pre>";
181163

182164
// and add it to the document.
183165
$dss = new DocumentSecurityStore($document);

0 commit comments

Comments
 (0)