1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace X509\CertificationPath\PathValidation; |
4
|
|
|
|
5
|
|
|
use CryptoUtil\Crypto\Crypto; |
6
|
|
|
use X509\Certificate\Certificate; |
7
|
|
|
use X509\Certificate\Extension\Extension; |
8
|
|
|
use X509\Certificate\TBSCertificate; |
9
|
|
|
use X509\CertificationPath\Exception\PathValidationException; |
10
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Implements certification path validation. |
14
|
|
|
* |
15
|
|
|
* @link https://tools.ietf.org/html/rfc5280#section-6 |
16
|
|
|
*/ |
17
|
|
|
class PathValidator |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* Crypto engine. |
21
|
|
|
* |
22
|
|
|
* @var Crypto $_crypto |
23
|
|
|
*/ |
24
|
|
|
protected $_crypto; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* Path validation configuration. |
28
|
|
|
* |
29
|
|
|
* @var PathValidationConfig $_config |
30
|
|
|
*/ |
31
|
|
|
protected $_config; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Certification path. |
35
|
|
|
* |
36
|
|
|
* @var Certificate[] $_certificates |
37
|
|
|
*/ |
38
|
|
|
protected $_certificates; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* Certification path trust anchor. |
42
|
|
|
* |
43
|
|
|
* @var Certificate $_trustAnchor |
44
|
|
|
*/ |
45
|
|
|
protected $_trustAnchor; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Constructor |
49
|
|
|
* |
50
|
|
|
* @param Crypto $crypto |
51
|
|
|
* @param PathValidationConfig $config |
52
|
|
|
* @param Certificate ...$certificates |
53
|
|
|
*/ |
54
|
23 |
|
public function __construct(Crypto $crypto, PathValidationConfig $config, |
55
|
|
|
Certificate ...$certificates) { |
56
|
23 |
|
if (!count($certificates)) { |
57
|
|
|
throw new \LogicException("No certificates."); |
58
|
|
|
} |
59
|
23 |
|
$this->_crypto = $crypto; |
60
|
23 |
|
$this->_config = $config; |
61
|
23 |
|
$this->_certificates = $certificates; |
62
|
|
|
// if trust anchor is explicitly given in configuration |
63
|
23 |
|
if ($config->hasTrustAnchor()) { |
64
|
|
|
$this->_trustAnchor = $config->trustAnchor(); |
65
|
|
|
} else { |
66
|
23 |
|
$this->_trustAnchor = $certificates[0]; |
67
|
|
|
} |
68
|
23 |
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Validate certification path. |
72
|
|
|
* |
73
|
|
|
* @throws PathValidationException |
74
|
|
|
* @return PathValidationResult |
75
|
|
|
*/ |
76
|
23 |
|
public function validate() { |
77
|
23 |
|
$n = count($this->_certificates); |
78
|
23 |
|
$state = ValidatorState::initialize($this->_config, $this->_trustAnchor, |
79
|
23 |
|
$n); |
80
|
23 |
|
for ($i = 0; $i < $n; ++$i) { |
81
|
|
|
// whether processing final certificate |
82
|
23 |
|
$state = $state->withIsFinal($i === $n - 1); |
83
|
23 |
|
$cert = $this->_certificates[$i]; |
84
|
|
|
// process certificate (section 6.1.3.) |
85
|
23 |
|
$state = $this->_processCertificate($state, $cert); |
86
|
22 |
|
if (!$state->isFinal()) { |
87
|
|
|
// prepare next certificate (section 6.1.4.) |
88
|
22 |
|
$state = $this->_prepareNext($state, $cert); |
89
|
18 |
|
} |
90
|
18 |
|
} |
91
|
12 |
|
if (!isset($cert)) { |
92
|
|
|
throw new \LogicException("No certificates."); |
93
|
|
|
} |
94
|
|
|
// wrap-up (section 6.1.5.) |
95
|
12 |
|
$this->_wrapUp($state, $cert); |
96
|
|
|
// return outputs |
97
|
11 |
|
return new PathValidationResult($cert, $state->validPolicyTree(), |
98
|
11 |
|
$state->workingPublicKey(), $state->workingPublicKeyAlgorithm(), |
99
|
11 |
|
$state->workingPublicKeyParameters()); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
/** |
103
|
|
|
* Apply basic certificate processing according to RFC 5280 section 6.1.3. |
104
|
|
|
* |
105
|
|
|
* @link https://tools.ietf.org/html/rfc5280#section-6.1.3 |
106
|
|
|
* @param ValidatorState $state |
107
|
|
|
* @param Certificate $cert |
108
|
|
|
* @throws PathValidationException |
109
|
|
|
* @return ValidatorState |
110
|
|
|
*/ |
111
|
23 |
|
protected function _processCertificate(ValidatorState $state, |
112
|
|
|
Certificate $cert) { |
113
|
|
|
// (a.1) verify signature |
114
|
23 |
|
$this->_verifySignature($state, $cert); |
115
|
|
|
// (a.2) check validity period |
116
|
23 |
|
$this->_checkValidity($cert); |
117
|
|
|
// (a.3) check that certificate is not revoked |
118
|
22 |
|
$this->_checkRevocation($cert); |
119
|
|
|
// (a.4) check issuer |
120
|
22 |
|
$this->_checkIssuer($state, $cert); |
121
|
|
|
// (b)(c) if certificate is self-issued and it is not |
122
|
|
|
// the final certificate in the path, skip this step |
123
|
22 |
|
if (!($cert->isSelfIssued() && !$state->isFinal())) { |
124
|
|
|
// (b) check permitted subtrees |
125
|
15 |
|
$this->_checkPermittedSubtrees($state, $cert); |
|
|
|
|
126
|
|
|
// (c) check excluded subtrees |
127
|
15 |
|
$this->_checkExcludedSubtrees($state, $cert); |
|
|
|
|
128
|
15 |
|
} |
129
|
22 |
|
$extensions = $cert->tbsCertificate()->extensions(); |
130
|
22 |
|
if ($extensions->hasCertificatePolicies()) { |
131
|
|
|
// (d) process policy information |
132
|
7 |
|
if ($state->hasValidPolicyTree()) { |
133
|
6 |
|
$state = $this->_processPolicyInformation($state, $cert); |
134
|
6 |
|
} |
135
|
7 |
|
} else { |
136
|
|
|
// (e) certificate policies extension not present, |
137
|
|
|
// set the valid_policy_tree to NULL |
138
|
18 |
|
$state = $state->withValidPolicyTree(null); |
139
|
|
|
} |
140
|
|
|
// (f) check that explicit_policy > 0 or valid_policy_tree is set |
141
|
22 |
|
if (!($state->explicitPolicy() > 0 || $state->hasValidPolicyTree())) { |
142
|
1 |
|
throw new PathValidationException("Policy error."); |
143
|
|
|
} |
144
|
22 |
|
return $state; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
/** |
148
|
|
|
* Apply preparation for certificate i+1 according to rfc5280 section 6.1.4. |
149
|
|
|
* |
150
|
|
|
* @link https://tools.ietf.org/html/rfc5280#section-6.1.4 |
151
|
|
|
* @param ValidatorState $state |
152
|
|
|
* @param Certificate $cert |
153
|
|
|
* @return ValidatorState |
154
|
|
|
*/ |
155
|
22 |
|
protected function _prepareNext(ValidatorState $state, Certificate $cert) { |
156
|
22 |
|
$tbs_cert = $cert->tbsCertificate(); |
157
|
22 |
|
$extensions = $tbs_cert->extensions(); |
158
|
|
|
// (a)(b) if policy mappings extension is present |
159
|
22 |
|
if ($extensions->hasPolicyMappings()) { |
160
|
|
|
// (a) verify that anyPolicy mapping is not used |
161
|
3 |
|
if ($extensions->policyMappings()->hasAnyPolicyMapping()) { |
162
|
1 |
|
throw new PathValidationException("anyPolicy mapping found."); |
163
|
|
|
} |
164
|
|
|
// (b) process policy mappings |
165
|
2 |
|
$state = $this->_processPolicyMappings($state, $cert); |
166
|
2 |
|
} |
167
|
|
|
// (c) assign working_issuer_name |
168
|
21 |
|
$state = $state->withWorkingIssuerName($tbs_cert->subject()); |
169
|
|
|
// (d)(e)(f) |
|
|
|
|
170
|
21 |
|
$state = $this->_setPublicKeyState($state, $cert); |
171
|
|
|
// (g) if name constraints extension is present |
172
|
21 |
|
if ($extensions->hasNameConstraints()) { |
173
|
1 |
|
$state = $this->_processNameConstraints($state, $cert); |
174
|
1 |
|
} |
175
|
|
|
// (h) if certificate is not self-issued |
176
|
21 |
|
if (!$cert->isSelfIssued()) { |
177
|
|
|
// (h.1) |
178
|
6 |
|
if ($state->explicitPolicy() > 0) { |
179
|
5 |
|
$state = $state->withExplicitPolicy( |
180
|
5 |
|
$state->explicitPolicy() - 1); |
181
|
5 |
|
} |
182
|
|
|
// (h.2) |
183
|
6 |
|
if ($state->policyMapping() > 0) { |
184
|
5 |
|
$state = $state->withPolicyMapping($state->policyMapping() - 1); |
185
|
5 |
|
} |
186
|
|
|
// (h.3) |
187
|
6 |
|
if ($state->inhibitAnyPolicy() > 0) { |
188
|
6 |
|
$state = $state->withInhibitAnyPolicy( |
189
|
6 |
|
$state->inhibitAnyPolicy() - 1); |
190
|
6 |
|
} |
191
|
6 |
|
} |
192
|
|
|
// (i) if policy constraints extension is present |
193
|
21 |
|
if ($extensions->hasPolicyConstraints()) { |
194
|
2 |
|
$ext = $extensions->policyConstraints(); |
195
|
|
|
// (i.1) |
196
|
2 |
|
if ($ext->hasRequireExplicitPolicy() && |
197
|
2 |
|
$ext->requireExplicitPolicy() < $state->explicitPolicy()) { |
198
|
2 |
|
$state = $state->withExplicitPolicy( |
199
|
2 |
|
$ext->requireExplicitPolicy()); |
200
|
2 |
|
} |
201
|
|
|
// (i.2) |
202
|
2 |
|
if ($ext->hasInhibitPolicyMapping() && |
203
|
2 |
|
$ext->inhibitPolicyMapping() < $state->policyMapping()) { |
204
|
1 |
|
$state = $state->withPolicyMapping($ext->inhibitPolicyMapping()); |
205
|
1 |
|
} |
206
|
2 |
|
} |
207
|
|
|
// (j) if inhibit any policy extension is present |
208
|
21 |
|
if ($extensions->hasInhibitAnyPolicy()) { |
209
|
1 |
|
$ext = $extensions->inhibitAnyPolicy(); |
210
|
1 |
|
if ($ext->skipCerts() < $state->inhibitAnyPolicy()) { |
211
|
1 |
|
$state = $state->withInhibitAnyPolicy($ext->skipCerts()); |
212
|
1 |
|
} |
213
|
1 |
|
} |
214
|
|
|
// (k) check basic constraints |
215
|
21 |
|
$this->_processBasicContraints($cert); |
216
|
|
|
// (l) verify max_path_length |
217
|
19 |
|
if (!$cert->isSelfIssued()) { |
218
|
6 |
|
if ($state->maxPathLength() <= 0) { |
219
|
2 |
|
throw new PathValidationException( |
220
|
2 |
|
"Certification path length exceeded."); |
221
|
|
|
} |
222
|
4 |
|
$state = $state->withMaxPathLength($state->maxPathLength() - 1); |
223
|
4 |
|
} |
224
|
|
|
// (m) check pathLenContraint |
225
|
19 |
|
$state = $this->_processPathLengthContraint($state, $cert); |
226
|
|
|
// (n) check key usage |
227
|
19 |
|
if ($extensions->hasKeyUsage()) { |
228
|
7 |
|
$ext = $extensions->keyUsage(); |
229
|
7 |
|
if (!$ext->isKeyCertSign()) { |
230
|
1 |
|
throw new PathValidationException("keyCertSign usage not set."); |
231
|
|
|
} |
232
|
6 |
|
} |
233
|
|
|
// (o) process relevant extensions |
234
|
18 |
|
$state = $this->_processExtensions($state, $cert); |
235
|
18 |
|
return $state; |
236
|
|
|
} |
237
|
|
|
|
238
|
|
|
/** |
239
|
|
|
* Apply wrap-up procedure according to RFC 5280 section 6.1.5. |
240
|
|
|
* |
241
|
|
|
* @link https://tools.ietf.org/html/rfc5280#section-6.1.5 |
242
|
|
|
* @param ValidatorState $state |
243
|
|
|
* @param Certificate $cert |
244
|
|
|
* @throws PathValidationException |
245
|
|
|
*/ |
246
|
12 |
|
protected function _wrapUp(ValidatorState $state, Certificate $cert) { |
247
|
12 |
|
$tbs_cert = $cert->tbsCertificate(); |
248
|
12 |
|
$extensions = $tbs_cert->extensions(); |
249
|
|
|
// (a) |
250
|
12 |
|
if ($state->explicitPolicy() > 0) { |
251
|
9 |
|
$state = $state->withExplicitPolicy($state->explicitPolicy() - 1); |
252
|
9 |
|
} |
253
|
|
|
// (b) |
254
|
12 |
|
if ($extensions->hasPolicyConstraints()) { |
255
|
2 |
|
$ext = $extensions->policyConstraints(); |
256
|
2 |
|
if ($ext->hasRequireExplicitPolicy() && |
257
|
2 |
|
$ext->requireExplicitPolicy() == 0) { |
258
|
1 |
|
$state = $state->withExplicitPolicy(0); |
259
|
1 |
|
} |
260
|
2 |
|
} |
261
|
|
|
// (c)(d)(e) |
|
|
|
|
262
|
12 |
|
$state = $this->_setPublicKeyState($state, $cert); |
263
|
|
|
// (f) process relevant extensions |
264
|
12 |
|
$state = $this->_processExtensions($state, $cert); |
265
|
|
|
// (g) intersection of valid_policy_tree and the initial-policy-set |
266
|
12 |
|
$state = $this->_calculatePolicyIntersection($state); |
267
|
|
|
// check that explicit_policy > 0 or valid_policy_tree is set |
268
|
12 |
|
if (!($state->explicitPolicy() > 0 || $state->hasValidPolicyTree())) { |
269
|
1 |
|
throw new PathValidationException("Policy error."); |
270
|
|
|
} |
271
|
|
|
// path validation succeeded |
272
|
11 |
|
} |
273
|
|
|
|
274
|
|
|
/** |
275
|
|
|
* Update working_public_key, working_public_key_parameters and |
276
|
|
|
* working_public_key_algorithm state variables from certificate. |
277
|
|
|
* |
278
|
|
|
* @param ValidatorState $state |
279
|
|
|
* @param Certificate $cert |
280
|
|
|
* @return ValidatorState |
281
|
|
|
*/ |
282
|
21 |
|
protected function _setPublicKeyState(ValidatorState $state, |
283
|
|
|
Certificate $cert) { |
284
|
21 |
|
$pk_info = $cert->tbsCertificate()->subjectPublicKeyInfo(); |
285
|
|
|
// assign working_public_key |
286
|
21 |
|
$state = $state->withWorkingPublicKey($pk_info); |
287
|
|
|
// assign working_public_key_parameters |
288
|
21 |
|
$params = ValidatorState::getAlgorithmParameters( |
289
|
21 |
|
$pk_info->algorithmIdentifier()); |
290
|
21 |
|
if (null !== $params) { |
291
|
21 |
|
$state = $state->withWorkingPublicKeyParameters($params); |
292
|
21 |
|
} else { |
293
|
|
|
// if algorithms differ, set parameters to null |
294
|
1 |
|
if ($pk_info->algorithmIdentifier()->oid() !== |
295
|
1 |
|
$state->workingPublicKeyAlgorithm()->oid()) { |
296
|
1 |
|
$state = $state->withWorkingPublicKeyParameters(null); |
297
|
1 |
|
} |
298
|
|
|
} |
299
|
|
|
// assign working_public_key_algorithm |
300
|
21 |
|
$state = $state->withWorkingPublicKeyAlgorithm( |
301
|
21 |
|
$pk_info->algorithmIdentifier()); |
302
|
21 |
|
return $state; |
303
|
|
|
} |
304
|
|
|
|
305
|
|
|
/** |
306
|
|
|
* Verify certificate signature. |
307
|
|
|
* |
308
|
|
|
* @param ValidatorState $state |
309
|
|
|
* @param Certificate $cert |
310
|
|
|
* @throws PathValidationException |
311
|
|
|
*/ |
312
|
23 |
|
protected function _verifySignature(ValidatorState $state, Certificate $cert) { |
313
|
23 |
|
if (!$cert->verify($this->_crypto, $state->workingPublicKey())) { |
314
|
1 |
|
throw new PathValidationException( |
315
|
1 |
|
"Certificate signature doesn't match."); |
316
|
|
|
} |
317
|
23 |
|
} |
318
|
|
|
|
319
|
|
|
/** |
320
|
|
|
* Check certificate validity. |
321
|
|
|
* |
322
|
|
|
* @param Certificate $cert |
323
|
|
|
* @throws PathValidationException |
324
|
|
|
*/ |
325
|
23 |
|
protected function _checkValidity(Certificate $cert) { |
326
|
23 |
|
$refdt = $this->_config->dateTime(); |
327
|
23 |
|
$validity = $cert->tbsCertificate()->validity(); |
328
|
23 |
|
if ($validity->notBefore() |
329
|
23 |
|
->dateTime() |
330
|
23 |
|
->diff($refdt)->invert) { |
331
|
1 |
|
throw new PathValidationException( |
332
|
1 |
|
"Certificate validity period has not started."); |
333
|
|
|
} |
334
|
22 |
|
if ($refdt->diff($validity->notAfter() |
335
|
22 |
|
->dateTime())->invert) { |
336
|
1 |
|
throw new PathValidationException("Certificate has expired."); |
337
|
|
|
} |
338
|
22 |
|
} |
339
|
|
|
|
340
|
|
|
/** |
341
|
|
|
* Check certificate revocation. |
342
|
|
|
* |
343
|
|
|
* @param Certificate $cert |
344
|
|
|
*/ |
345
|
22 |
|
protected function _checkRevocation(Certificate $cert) { |
|
|
|
|
346
|
|
|
// @todo Implement CRL handling |
347
|
22 |
|
} |
348
|
|
|
|
349
|
|
|
/** |
350
|
|
|
* Check certificate issuer. |
351
|
|
|
* |
352
|
|
|
* @param ValidatorState $state |
353
|
|
|
* @param Certificate $cert |
354
|
|
|
* @throws PathValidationException |
355
|
|
|
*/ |
356
|
22 |
|
protected function _checkIssuer(ValidatorState $state, Certificate $cert) { |
357
|
22 |
|
if (!$cert->tbsCertificate() |
358
|
22 |
|
->issuer() |
359
|
22 |
|
->equals($state->workingIssuerName())) { |
|
|
|
|
360
|
1 |
|
throw new PathValidationException("Certification issuer mismatch."); |
361
|
|
|
} |
362
|
22 |
|
} |
363
|
|
|
|
364
|
|
|
/** |
365
|
|
|
* |
366
|
|
|
* @param ValidatorState $state |
367
|
|
|
* @param Certificate $cert |
368
|
|
|
*/ |
369
|
15 |
|
protected function _checkPermittedSubtrees(ValidatorState $state, |
370
|
|
|
Certificate $cert) { |
|
|
|
|
371
|
|
|
// @todo Implement |
372
|
15 |
|
$state->permittedSubtrees(); |
|
|
|
|
373
|
15 |
|
} |
374
|
|
|
|
375
|
|
|
/** |
376
|
|
|
* |
377
|
|
|
* @param ValidatorState $state |
378
|
|
|
* @param Certificate $cert |
379
|
|
|
*/ |
380
|
15 |
|
protected function _checkExcludedSubtrees(ValidatorState $state, |
381
|
|
|
Certificate $cert) { |
|
|
|
|
382
|
|
|
// @todo Implement |
383
|
15 |
|
$state->excludedSubtrees(); |
|
|
|
|
384
|
15 |
|
} |
385
|
|
|
|
386
|
|
|
/** |
387
|
|
|
* |
388
|
|
|
* @param ValidatorState $state |
389
|
|
|
* @param Certificate $cert |
390
|
|
|
* @return ValidatorState |
391
|
|
|
*/ |
392
|
6 |
|
protected function _processPolicyInformation(ValidatorState $state, |
393
|
|
|
Certificate $cert) { |
|
|
|
|
394
|
|
|
// @todo Implement |
395
|
6 |
|
return $state; |
396
|
|
|
} |
397
|
|
|
|
398
|
|
|
/** |
399
|
|
|
* |
400
|
|
|
* @param ValidatorState $state |
401
|
|
|
* @param Certificate $cert |
402
|
|
|
* @return ValidatorState |
403
|
|
|
*/ |
404
|
1 |
|
protected function _processNameConstraints(ValidatorState $state, |
405
|
|
|
Certificate $cert) { |
|
|
|
|
406
|
|
|
// @todo Implement |
407
|
1 |
|
return $state; |
408
|
|
|
} |
409
|
|
|
|
410
|
|
|
/** |
411
|
|
|
* Process basic constraints extension. |
412
|
|
|
* |
413
|
|
|
* @param Certificate $cert |
414
|
|
|
* @throws PathValidationException |
415
|
|
|
*/ |
416
|
21 |
|
protected function _processBasicContraints(Certificate $cert) { |
417
|
21 |
|
if ($cert->tbsCertificate()->version() == TBSCertificate::VERSION_3) { |
418
|
18 |
|
$extensions = $cert->tbsCertificate()->extensions(); |
419
|
18 |
|
if (!$extensions->hasBasicConstraints()) { |
420
|
1 |
|
throw new PathValidationException( |
421
|
1 |
|
"v3 certificate must have basicConstraints extension."); |
422
|
|
|
} |
423
|
|
|
// verify that cA is set to TRUE |
424
|
17 |
|
if (!$extensions->basicConstraints()->isCA()) { |
425
|
1 |
|
throw new PathValidationException( |
426
|
1 |
|
"Certificate is not a CA certificate."); |
427
|
|
|
} |
428
|
16 |
|
} |
429
|
19 |
|
} |
430
|
|
|
|
431
|
|
|
/** |
432
|
|
|
* Process pathLenConstraint. |
433
|
|
|
* |
434
|
|
|
* @param ValidatorState $state |
435
|
|
|
* @param Certificate $cert |
436
|
|
|
* @return ValidatorState |
437
|
|
|
*/ |
438
|
19 |
|
protected function _processPathLengthContraint(ValidatorState $state, |
439
|
|
|
Certificate $cert) { |
440
|
19 |
|
$extensions = $cert->tbsCertificate()->extensions(); |
441
|
19 |
|
if ($extensions->hasBasicConstraints()) { |
442
|
16 |
|
$ext = $extensions->basicConstraints(); |
443
|
16 |
|
if ($ext->hasPathLen()) { |
444
|
12 |
|
if ($ext->pathLen() < $state->maxPathLength()) { |
445
|
8 |
|
$state = $state->withMaxPathLength($ext->pathLen()); |
446
|
8 |
|
} |
447
|
12 |
|
} |
448
|
16 |
|
} |
449
|
19 |
|
return $state; |
450
|
|
|
} |
451
|
|
|
|
452
|
|
|
/** |
453
|
|
|
* Process policy mappings extension. |
454
|
|
|
* |
455
|
|
|
* @param ValidatorState $state |
456
|
|
|
* @param Certificate $cert |
457
|
|
|
* @return ValidatorState |
458
|
|
|
*/ |
459
|
2 |
|
protected function _processPolicyMappings(ValidatorState $state, |
460
|
|
|
Certificate $cert) { |
|
|
|
|
461
|
|
|
// @todo Implement |
462
|
2 |
|
return $state; |
463
|
|
|
} |
464
|
|
|
|
465
|
|
|
/** |
466
|
|
|
* |
467
|
|
|
* @param ValidatorState $state |
468
|
|
|
* @param Certificate $cert |
469
|
|
|
* @return ValidatorState |
470
|
|
|
*/ |
471
|
18 |
|
protected function _processExtensions(ValidatorState $state, |
472
|
|
|
Certificate $cert) { |
|
|
|
|
473
|
|
|
// @todo Implement |
474
|
18 |
|
return $state; |
475
|
|
|
} |
476
|
|
|
|
477
|
|
|
/** |
478
|
|
|
* |
479
|
|
|
* @param ValidatorState $state |
480
|
|
|
* @return ValidatorState |
481
|
|
|
*/ |
482
|
12 |
|
protected function _calculatePolicyIntersection(ValidatorState $state) { |
483
|
|
|
// @todo Implement |
484
|
12 |
|
return $state; |
485
|
|
|
} |
486
|
|
|
} |
487
|
|
|
|
PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.
Let’s take a look at an example:
If we look at the
getEmail()
method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:On the hand, if we look at the
setEmail()
, this method _has_ side-effects. In the following case, we could not remove the method call: