1 | <?php |
||
13 | class CertificateChain implements \Countable, \IteratorAggregate |
||
14 | { |
||
15 | /** |
||
16 | * List of certificates in a chain. |
||
17 | * |
||
18 | * @var Certificate[] |
||
19 | */ |
||
20 | protected $_certs; |
||
21 | |||
22 | /** |
||
23 | * Constructor. |
||
24 | * |
||
25 | * @param Certificate ...$certs List of certificates, end-entity first |
||
26 | */ |
||
27 | 6 | public function __construct(Certificate ...$certs) { |
|
30 | |||
31 | /** |
||
32 | * Initialize from a list of PEMs. |
||
33 | * |
||
34 | * @param PEM ...$pems |
||
35 | * @return self |
||
36 | */ |
||
37 | 2 | public static function fromPEMs(PEM ...$pems) { |
|
44 | |||
45 | /** |
||
46 | * Initialize from a string containing multiple PEM blocks. |
||
47 | * |
||
48 | * @param string $str |
||
49 | * @return self |
||
50 | */ |
||
51 | 1 | public static function fromPEMString($str) { |
|
55 | |||
56 | /** |
||
57 | * Get all certificates in a chain ordered from the end-entity certificate |
||
58 | * to the trust anchor. |
||
59 | * |
||
60 | * @return Certificate[] |
||
61 | */ |
||
62 | 3 | public function certificates() { |
|
65 | |||
66 | /** |
||
67 | * Get the end-entity certificate. |
||
68 | * |
||
69 | * @throws \LogicException |
||
70 | * @return Certificate |
||
71 | */ |
||
72 | 2 | public function endEntityCertificate() { |
|
78 | |||
79 | /** |
||
80 | * Get the trust anchor certificate. |
||
81 | * |
||
82 | * @throws \LogicException |
||
83 | * @return Certificate |
||
84 | */ |
||
85 | 2 | public function trustAnchorCertificate() { |
|
91 | |||
92 | /** |
||
93 | * Convert certificate chain to certification path. |
||
94 | * |
||
95 | * @return CertificationPath |
||
96 | */ |
||
97 | 1 | public function certificationPath() { |
|
100 | |||
101 | /** |
||
102 | * Convert certificate chain to string of PEM blocks. |
||
103 | * |
||
104 | * @return string |
||
105 | */ |
||
106 | 1 | public function toPEMString() { |
|
113 | |||
114 | /** |
||
115 | * |
||
116 | * @see Countable::count() |
||
117 | * @return int |
||
118 | */ |
||
119 | 1 | public function count() { |
|
122 | |||
123 | /** |
||
124 | * Get iterator for certificates. |
||
125 | * |
||
126 | * @see IteratorAggregate::getIterator() |
||
127 | * @return \ArrayIterator |
||
128 | */ |
||
129 | 2 | public function getIterator() { |
|
132 | } |
||
133 |