|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace X509\CertificationPath\PathValidation; |
|
4
|
|
|
|
|
5
|
|
|
use ASN1\Element; |
|
6
|
|
|
use CryptoUtil\ASN1\AlgorithmIdentifier\Feature\AlgorithmIdentifierType; |
|
7
|
|
|
use CryptoUtil\ASN1\PublicKeyInfo; |
|
8
|
|
|
use X509\Certificate\Certificate; |
|
9
|
|
|
use X509\Certificate\Extension\CertificatePolicy\PolicyInformation; |
|
10
|
|
|
use X509\CertificationPath\Policy\PolicyTree; |
|
11
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Result of the path validation process. |
|
15
|
|
|
* |
|
16
|
|
|
* @link https://tools.ietf.org/html/rfc5280#section-6.1.6 |
|
17
|
|
|
*/ |
|
18
|
|
|
class PathValidationResult |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Certificates in a certification path. |
|
22
|
|
|
* |
|
23
|
|
|
* @var Certificate[] $_certificates |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $_certificates; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* Valid policy tree. |
|
29
|
|
|
* |
|
30
|
|
|
* @var PolicyTree|null $_policyTree |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $_policyTree; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* End-entity certificate's public key. |
|
36
|
|
|
* |
|
37
|
|
|
* @var PublicKeyInfo |
|
38
|
|
|
*/ |
|
39
|
|
|
protected $_publicKeyInfo; |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Public key algorithm. |
|
43
|
|
|
* |
|
44
|
|
|
* @var AlgorithmIdentifierType |
|
45
|
|
|
*/ |
|
46
|
|
|
protected $_publicKeyAlgo; |
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Public key parameters. |
|
50
|
|
|
* |
|
51
|
|
|
* @var Element|null $_publicKeyParameters |
|
52
|
|
|
*/ |
|
53
|
|
|
protected $_publicKeyParameters; |
|
54
|
|
|
|
|
55
|
|
|
/** |
|
56
|
|
|
* Constructor |
|
57
|
|
|
* |
|
58
|
|
|
* @param array $certificates |
|
59
|
|
|
* @param PolicyTree|null $policy_tree |
|
60
|
|
|
* @param PublicKeyInfo $pubkey_info |
|
61
|
|
|
* @param AlgorithmIdentifierType $algo |
|
62
|
|
|
* @param Element|null $params |
|
63
|
|
|
*/ |
|
64
|
28 |
|
public function __construct(array $certificates, $policy_tree, |
|
65
|
|
|
PublicKeyInfo $pubkey_info, AlgorithmIdentifierType $algo, |
|
66
|
|
|
Element $params = null) { |
|
67
|
28 |
|
$this->_certificates = array_values($certificates); |
|
|
|
|
|
|
68
|
28 |
|
$this->_policyTree = $policy_tree; |
|
69
|
28 |
|
$this->_publicKeyInfo = $pubkey_info; |
|
70
|
28 |
|
$this->_publicKeyAlgo = $algo; |
|
71
|
28 |
|
$this->_publicKeyParameters = $params; |
|
72
|
28 |
|
} |
|
73
|
|
|
|
|
74
|
|
|
/** |
|
75
|
|
|
* Get end-entity certificate. |
|
76
|
|
|
* |
|
77
|
|
|
* @return Certificate |
|
78
|
|
|
*/ |
|
79
|
12 |
|
public function certificate() { |
|
80
|
12 |
|
return $this->_certificates[count($this->_certificates) - 1]; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* Get certificate policies of the end-entity certificate. |
|
85
|
|
|
* |
|
86
|
|
|
* @return PolicyInformation[] |
|
87
|
|
|
*/ |
|
88
|
6 |
|
public function policies() { |
|
89
|
6 |
|
if (!$this->_policyTree) { |
|
90
|
1 |
|
return array(); |
|
91
|
|
|
} |
|
92
|
5 |
|
return $this->_policyTree->policiesAtDepth(count($this->_certificates)); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..