GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Test Failed
Push — master ( 405cf3...79c9ba )
by Joni
04:48
created
lib/X509/Certificate/Extension/IssuerAlternativeNameExtension.php 1 patch
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -15,50 +15,50 @@
 block discarded – undo
15 15
  */
16 16
 class IssuerAlternativeNameExtension extends Extension
17 17
 {
18
-    /**
19
-     * Names.
20
-     *
21
-     * @var GeneralNames
22
-     */
23
-    protected $_names;
18
+	/**
19
+	 * Names.
20
+	 *
21
+	 * @var GeneralNames
22
+	 */
23
+	protected $_names;
24 24
 
25
-    /**
26
-     * Constructor.
27
-     *
28
-     * @param bool         $critical
29
-     * @param GeneralNames $names
30
-     */
31
-    public function __construct(bool $critical, GeneralNames $names)
32
-    {
33
-        parent::__construct(self::OID_ISSUER_ALT_NAME, $critical);
34
-        $this->_names = $names;
35
-    }
25
+	/**
26
+	 * Constructor.
27
+	 *
28
+	 * @param bool         $critical
29
+	 * @param GeneralNames $names
30
+	 */
31
+	public function __construct(bool $critical, GeneralNames $names)
32
+	{
33
+		parent::__construct(self::OID_ISSUER_ALT_NAME, $critical);
34
+		$this->_names = $names;
35
+	}
36 36
 
37
-    /**
38
-     * Get names.
39
-     *
40
-     * @return GeneralNames
41
-     */
42
-    public function names(): GeneralNames
43
-    {
44
-        return $this->_names;
45
-    }
37
+	/**
38
+	 * Get names.
39
+	 *
40
+	 * @return GeneralNames
41
+	 */
42
+	public function names(): GeneralNames
43
+	{
44
+		return $this->_names;
45
+	}
46 46
 
47
-    /**
48
-     * {@inheritdoc}
49
-     */
50
-    protected static function _fromDER(string $data, bool $critical): Extension
51
-    {
52
-        return new self($critical,
53
-            GeneralNames::fromASN1(
54
-                UnspecifiedType::fromDER($data)->asSequence()));
55
-    }
47
+	/**
48
+	 * {@inheritdoc}
49
+	 */
50
+	protected static function _fromDER(string $data, bool $critical): Extension
51
+	{
52
+		return new self($critical,
53
+			GeneralNames::fromASN1(
54
+				UnspecifiedType::fromDER($data)->asSequence()));
55
+	}
56 56
 
57
-    /**
58
-     * {@inheritdoc}
59
-     */
60
-    protected function _valueASN1(): Element
61
-    {
62
-        return $this->_names->toASN1();
63
-    }
57
+	/**
58
+	 * {@inheritdoc}
59
+	 */
60
+	protected function _valueASN1(): Element
61
+	{
62
+		return $this->_names->toASN1();
63
+	}
64 64
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/AAControlsExtension.php 1 patch
Indentation   +203 added lines, -203 removed lines patch added patch discarded remove patch
@@ -19,207 +19,207 @@
 block discarded – undo
19 19
  */
20 20
 class AAControlsExtension extends Extension
21 21
 {
22
-    /**
23
-     * Path length contraint.
24
-     *
25
-     * @var null|int
26
-     */
27
-    protected $_pathLenConstraint;
28
-
29
-    /**
30
-     * Permitted attributes.
31
-     *
32
-     * Array of OID's.
33
-     *
34
-     * @var null|string[]
35
-     */
36
-    protected $_permittedAttrs;
37
-
38
-    /**
39
-     * Excluded attributes.
40
-     *
41
-     * Array of OID's.
42
-     *
43
-     * @var null|string[]
44
-     */
45
-    protected $_excludedAttrs;
46
-
47
-    /**
48
-     * Whether to permit unspecified attributes.
49
-     *
50
-     * @var bool
51
-     */
52
-    protected $_permitUnSpecified;
53
-
54
-    /**
55
-     * Constructor.
56
-     *
57
-     * @param bool          $critical
58
-     * @param null|int      $path_len
59
-     * @param null|string[] $permitted
60
-     * @param null|string[] $excluded
61
-     * @param bool          $permit_unspecified
62
-     */
63
-    public function __construct(bool $critical, ?int $path_len = null,
64
-        ?array $permitted = null, ?array $excluded = null, bool $permit_unspecified = true)
65
-    {
66
-        parent::__construct(self::OID_AA_CONTROLS, $critical);
67
-        $this->_pathLenConstraint = $path_len;
68
-        $this->_permittedAttrs = $permitted;
69
-        $this->_excludedAttrs = $excluded;
70
-        $this->_permitUnSpecified = $permit_unspecified;
71
-    }
72
-
73
-    /**
74
-     * Check whether path length constraint is present.
75
-     *
76
-     * @return bool
77
-     */
78
-    public function hasPathLen(): bool
79
-    {
80
-        return isset($this->_pathLenConstraint);
81
-    }
82
-
83
-    /**
84
-     * Get path length constraint.
85
-     *
86
-     * @throws \LogicException If not set
87
-     *
88
-     * @return int
89
-     */
90
-    public function pathLen(): int
91
-    {
92
-        if (!$this->hasPathLen()) {
93
-            throw new \LogicException('pathLen not set.');
94
-        }
95
-        return $this->_pathLenConstraint;
96
-    }
97
-
98
-    /**
99
-     * Check whether permitted attributes are present.
100
-     *
101
-     * @return bool
102
-     */
103
-    public function hasPermittedAttrs(): bool
104
-    {
105
-        return isset($this->_permittedAttrs);
106
-    }
107
-
108
-    /**
109
-     * Get OID's of permitted attributes.
110
-     *
111
-     * @throws \LogicException If not set
112
-     *
113
-     * @return string[]
114
-     */
115
-    public function permittedAttrs(): array
116
-    {
117
-        if (!$this->hasPermittedAttrs()) {
118
-            throw new \LogicException('permittedAttrs not set.');
119
-        }
120
-        return $this->_permittedAttrs;
121
-    }
122
-
123
-    /**
124
-     * Check whether excluded attributes are present.
125
-     *
126
-     * @return bool
127
-     */
128
-    public function hasExcludedAttrs(): bool
129
-    {
130
-        return isset($this->_excludedAttrs);
131
-    }
132
-
133
-    /**
134
-     * Get OID's of excluded attributes.
135
-     *
136
-     * @throws \LogicException If not set
137
-     *
138
-     * @return string[]
139
-     */
140
-    public function excludedAttrs(): array
141
-    {
142
-        if (!$this->hasExcludedAttrs()) {
143
-            throw new \LogicException('excludedAttrs not set.');
144
-        }
145
-        return $this->_excludedAttrs;
146
-    }
147
-
148
-    /**
149
-     * Whether to permit attributes that are not explicitly specified in
150
-     * neither permitted nor excluded list.
151
-     *
152
-     * @return bool
153
-     */
154
-    public function permitUnspecified(): bool
155
-    {
156
-        return $this->_permitUnSpecified;
157
-    }
158
-
159
-    /**
160
-     * {@inheritdoc}
161
-     */
162
-    protected static function _fromDER(string $data, bool $critical): Extension
163
-    {
164
-        $seq = UnspecifiedType::fromDER($data)->asSequence();
165
-        $path_len = null;
166
-        $permitted = null;
167
-        $excluded = null;
168
-        $permit_unspecified = true;
169
-        $idx = 0;
170
-        if ($seq->has($idx, Element::TYPE_INTEGER)) {
171
-            $path_len = $seq->at($idx++)->asInteger()->intNumber();
172
-        }
173
-        if ($seq->hasTagged(0)) {
174
-            $attr_seq = $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
175
-                ->asSequence();
176
-            $permitted = array_map(
177
-                function (UnspecifiedType $el) {
178
-                    return $el->asObjectIdentifier()->oid();
179
-                }, $attr_seq->elements());
180
-            ++$idx;
181
-        }
182
-        if ($seq->hasTagged(1)) {
183
-            $attr_seq = $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
184
-                ->asSequence();
185
-            $excluded = array_map(
186
-                function (UnspecifiedType $el) {
187
-                    return $el->asObjectIdentifier()->oid();
188
-                }, $attr_seq->elements());
189
-            ++$idx;
190
-        }
191
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
192
-            $permit_unspecified = $seq->at($idx++)->asBoolean()->value();
193
-        }
194
-        return new self($critical, $path_len, $permitted, $excluded, $permit_unspecified);
195
-    }
196
-
197
-    /**
198
-     * {@inheritdoc}
199
-     */
200
-    protected function _valueASN1(): Element
201
-    {
202
-        $elements = [];
203
-        if (isset($this->_pathLenConstraint)) {
204
-            $elements[] = new Integer($this->_pathLenConstraint);
205
-        }
206
-        if (isset($this->_permittedAttrs)) {
207
-            $oids = array_map(
208
-                function ($oid) {
209
-                    return new ObjectIdentifier($oid);
210
-                }, $this->_permittedAttrs);
211
-            $elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
212
-        }
213
-        if (isset($this->_excludedAttrs)) {
214
-            $oids = array_map(
215
-                function ($oid) {
216
-                    return new ObjectIdentifier($oid);
217
-                }, $this->_excludedAttrs);
218
-            $elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
219
-        }
220
-        if (true !== $this->_permitUnSpecified) {
221
-            $elements[] = new Boolean(false);
222
-        }
223
-        return new Sequence(...$elements);
224
-    }
22
+	/**
23
+	 * Path length contraint.
24
+	 *
25
+	 * @var null|int
26
+	 */
27
+	protected $_pathLenConstraint;
28
+
29
+	/**
30
+	 * Permitted attributes.
31
+	 *
32
+	 * Array of OID's.
33
+	 *
34
+	 * @var null|string[]
35
+	 */
36
+	protected $_permittedAttrs;
37
+
38
+	/**
39
+	 * Excluded attributes.
40
+	 *
41
+	 * Array of OID's.
42
+	 *
43
+	 * @var null|string[]
44
+	 */
45
+	protected $_excludedAttrs;
46
+
47
+	/**
48
+	 * Whether to permit unspecified attributes.
49
+	 *
50
+	 * @var bool
51
+	 */
52
+	protected $_permitUnSpecified;
53
+
54
+	/**
55
+	 * Constructor.
56
+	 *
57
+	 * @param bool          $critical
58
+	 * @param null|int      $path_len
59
+	 * @param null|string[] $permitted
60
+	 * @param null|string[] $excluded
61
+	 * @param bool          $permit_unspecified
62
+	 */
63
+	public function __construct(bool $critical, ?int $path_len = null,
64
+		?array $permitted = null, ?array $excluded = null, bool $permit_unspecified = true)
65
+	{
66
+		parent::__construct(self::OID_AA_CONTROLS, $critical);
67
+		$this->_pathLenConstraint = $path_len;
68
+		$this->_permittedAttrs = $permitted;
69
+		$this->_excludedAttrs = $excluded;
70
+		$this->_permitUnSpecified = $permit_unspecified;
71
+	}
72
+
73
+	/**
74
+	 * Check whether path length constraint is present.
75
+	 *
76
+	 * @return bool
77
+	 */
78
+	public function hasPathLen(): bool
79
+	{
80
+		return isset($this->_pathLenConstraint);
81
+	}
82
+
83
+	/**
84
+	 * Get path length constraint.
85
+	 *
86
+	 * @throws \LogicException If not set
87
+	 *
88
+	 * @return int
89
+	 */
90
+	public function pathLen(): int
91
+	{
92
+		if (!$this->hasPathLen()) {
93
+			throw new \LogicException('pathLen not set.');
94
+		}
95
+		return $this->_pathLenConstraint;
96
+	}
97
+
98
+	/**
99
+	 * Check whether permitted attributes are present.
100
+	 *
101
+	 * @return bool
102
+	 */
103
+	public function hasPermittedAttrs(): bool
104
+	{
105
+		return isset($this->_permittedAttrs);
106
+	}
107
+
108
+	/**
109
+	 * Get OID's of permitted attributes.
110
+	 *
111
+	 * @throws \LogicException If not set
112
+	 *
113
+	 * @return string[]
114
+	 */
115
+	public function permittedAttrs(): array
116
+	{
117
+		if (!$this->hasPermittedAttrs()) {
118
+			throw new \LogicException('permittedAttrs not set.');
119
+		}
120
+		return $this->_permittedAttrs;
121
+	}
122
+
123
+	/**
124
+	 * Check whether excluded attributes are present.
125
+	 *
126
+	 * @return bool
127
+	 */
128
+	public function hasExcludedAttrs(): bool
129
+	{
130
+		return isset($this->_excludedAttrs);
131
+	}
132
+
133
+	/**
134
+	 * Get OID's of excluded attributes.
135
+	 *
136
+	 * @throws \LogicException If not set
137
+	 *
138
+	 * @return string[]
139
+	 */
140
+	public function excludedAttrs(): array
141
+	{
142
+		if (!$this->hasExcludedAttrs()) {
143
+			throw new \LogicException('excludedAttrs not set.');
144
+		}
145
+		return $this->_excludedAttrs;
146
+	}
147
+
148
+	/**
149
+	 * Whether to permit attributes that are not explicitly specified in
150
+	 * neither permitted nor excluded list.
151
+	 *
152
+	 * @return bool
153
+	 */
154
+	public function permitUnspecified(): bool
155
+	{
156
+		return $this->_permitUnSpecified;
157
+	}
158
+
159
+	/**
160
+	 * {@inheritdoc}
161
+	 */
162
+	protected static function _fromDER(string $data, bool $critical): Extension
163
+	{
164
+		$seq = UnspecifiedType::fromDER($data)->asSequence();
165
+		$path_len = null;
166
+		$permitted = null;
167
+		$excluded = null;
168
+		$permit_unspecified = true;
169
+		$idx = 0;
170
+		if ($seq->has($idx, Element::TYPE_INTEGER)) {
171
+			$path_len = $seq->at($idx++)->asInteger()->intNumber();
172
+		}
173
+		if ($seq->hasTagged(0)) {
174
+			$attr_seq = $seq->getTagged(0)->asImplicit(Element::TYPE_SEQUENCE)
175
+				->asSequence();
176
+			$permitted = array_map(
177
+				function (UnspecifiedType $el) {
178
+					return $el->asObjectIdentifier()->oid();
179
+				}, $attr_seq->elements());
180
+			++$idx;
181
+		}
182
+		if ($seq->hasTagged(1)) {
183
+			$attr_seq = $seq->getTagged(1)->asImplicit(Element::TYPE_SEQUENCE)
184
+				->asSequence();
185
+			$excluded = array_map(
186
+				function (UnspecifiedType $el) {
187
+					return $el->asObjectIdentifier()->oid();
188
+				}, $attr_seq->elements());
189
+			++$idx;
190
+		}
191
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
192
+			$permit_unspecified = $seq->at($idx++)->asBoolean()->value();
193
+		}
194
+		return new self($critical, $path_len, $permitted, $excluded, $permit_unspecified);
195
+	}
196
+
197
+	/**
198
+	 * {@inheritdoc}
199
+	 */
200
+	protected function _valueASN1(): Element
201
+	{
202
+		$elements = [];
203
+		if (isset($this->_pathLenConstraint)) {
204
+			$elements[] = new Integer($this->_pathLenConstraint);
205
+		}
206
+		if (isset($this->_permittedAttrs)) {
207
+			$oids = array_map(
208
+				function ($oid) {
209
+					return new ObjectIdentifier($oid);
210
+				}, $this->_permittedAttrs);
211
+			$elements[] = new ImplicitlyTaggedType(0, new Sequence(...$oids));
212
+		}
213
+		if (isset($this->_excludedAttrs)) {
214
+			$oids = array_map(
215
+				function ($oid) {
216
+					return new ObjectIdentifier($oid);
217
+				}, $this->_excludedAttrs);
218
+			$elements[] = new ImplicitlyTaggedType(1, new Sequence(...$oids));
219
+		}
220
+		if (true !== $this->_permitUnSpecified) {
221
+			$elements[] = new Boolean(false);
222
+		}
223
+		return new Sequence(...$elements);
224
+	}
225 225
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/Extension/BasicConstraintsExtension.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -17,99 +17,99 @@
 block discarded – undo
17 17
  */
18 18
 class BasicConstraintsExtension extends Extension
19 19
 {
20
-    /**
21
-     * Whether certificate is a CA.
22
-     *
23
-     * @var bool
24
-     */
25
-    protected $_ca;
20
+	/**
21
+	 * Whether certificate is a CA.
22
+	 *
23
+	 * @var bool
24
+	 */
25
+	protected $_ca;
26 26
 
27
-    /**
28
-     * Maximum certification path length.
29
-     *
30
-     * @var null|int
31
-     */
32
-    protected $_pathLen;
27
+	/**
28
+	 * Maximum certification path length.
29
+	 *
30
+	 * @var null|int
31
+	 */
32
+	protected $_pathLen;
33 33
 
34
-    /**
35
-     * Constructor.
36
-     *
37
-     * @param bool     $critical
38
-     * @param bool     $ca
39
-     * @param null|int $path_len
40
-     */
41
-    public function __construct(bool $critical, bool $ca, ?int $path_len = null)
42
-    {
43
-        parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical);
44
-        $this->_ca = $ca;
45
-        $this->_pathLen = $path_len;
46
-    }
34
+	/**
35
+	 * Constructor.
36
+	 *
37
+	 * @param bool     $critical
38
+	 * @param bool     $ca
39
+	 * @param null|int $path_len
40
+	 */
41
+	public function __construct(bool $critical, bool $ca, ?int $path_len = null)
42
+	{
43
+		parent::__construct(self::OID_BASIC_CONSTRAINTS, $critical);
44
+		$this->_ca = $ca;
45
+		$this->_pathLen = $path_len;
46
+	}
47 47
 
48
-    /**
49
-     * Whether certificate is a CA.
50
-     *
51
-     * @return bool
52
-     */
53
-    public function isCA(): bool
54
-    {
55
-        return $this->_ca;
56
-    }
48
+	/**
49
+	 * Whether certificate is a CA.
50
+	 *
51
+	 * @return bool
52
+	 */
53
+	public function isCA(): bool
54
+	{
55
+		return $this->_ca;
56
+	}
57 57
 
58
-    /**
59
-     * Whether path length is present.
60
-     *
61
-     * @return bool
62
-     */
63
-    public function hasPathLen(): bool
64
-    {
65
-        return isset($this->_pathLen);
66
-    }
58
+	/**
59
+	 * Whether path length is present.
60
+	 *
61
+	 * @return bool
62
+	 */
63
+	public function hasPathLen(): bool
64
+	{
65
+		return isset($this->_pathLen);
66
+	}
67 67
 
68
-    /**
69
-     * Get path length.
70
-     *
71
-     * @throws \LogicException If not set
72
-     *
73
-     * @return int
74
-     */
75
-    public function pathLen(): int
76
-    {
77
-        if (!$this->hasPathLen()) {
78
-            throw new \LogicException('pathLenConstraint not set.');
79
-        }
80
-        return $this->_pathLen;
81
-    }
68
+	/**
69
+	 * Get path length.
70
+	 *
71
+	 * @throws \LogicException If not set
72
+	 *
73
+	 * @return int
74
+	 */
75
+	public function pathLen(): int
76
+	{
77
+		if (!$this->hasPathLen()) {
78
+			throw new \LogicException('pathLenConstraint not set.');
79
+		}
80
+		return $this->_pathLen;
81
+	}
82 82
 
83
-    /**
84
-     * {@inheritdoc}
85
-     */
86
-    protected static function _fromDER(string $data, bool $critical): Extension
87
-    {
88
-        $seq = UnspecifiedType::fromDER($data)->asSequence();
89
-        $ca = false;
90
-        $path_len = null;
91
-        $idx = 0;
92
-        if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
93
-            $ca = $seq->at($idx++)->asBoolean()->value();
94
-        }
95
-        if ($seq->has($idx, Element::TYPE_INTEGER)) {
96
-            $path_len = $seq->at($idx)->asInteger()->intNumber();
97
-        }
98
-        return new self($critical, $ca, $path_len);
99
-    }
83
+	/**
84
+	 * {@inheritdoc}
85
+	 */
86
+	protected static function _fromDER(string $data, bool $critical): Extension
87
+	{
88
+		$seq = UnspecifiedType::fromDER($data)->asSequence();
89
+		$ca = false;
90
+		$path_len = null;
91
+		$idx = 0;
92
+		if ($seq->has($idx, Element::TYPE_BOOLEAN)) {
93
+			$ca = $seq->at($idx++)->asBoolean()->value();
94
+		}
95
+		if ($seq->has($idx, Element::TYPE_INTEGER)) {
96
+			$path_len = $seq->at($idx)->asInteger()->intNumber();
97
+		}
98
+		return new self($critical, $ca, $path_len);
99
+	}
100 100
 
101
-    /**
102
-     * {@inheritdoc}
103
-     */
104
-    protected function _valueASN1(): Element
105
-    {
106
-        $elements = [];
107
-        if ($this->_ca) {
108
-            $elements[] = new Boolean(true);
109
-        }
110
-        if (isset($this->_pathLen)) {
111
-            $elements[] = new Integer($this->_pathLen);
112
-        }
113
-        return new Sequence(...$elements);
114
-    }
101
+	/**
102
+	 * {@inheritdoc}
103
+	 */
104
+	protected function _valueASN1(): Element
105
+	{
106
+		$elements = [];
107
+		if ($this->_ca) {
108
+			$elements[] = new Boolean(true);
109
+		}
110
+		if (isset($this->_pathLen)) {
111
+			$elements[] = new Integer($this->_pathLen);
112
+		}
113
+		return new Sequence(...$elements);
114
+	}
115 115
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/CertificateBundle.php 1 patch
Indentation   +211 added lines, -211 removed lines patch added patch discarded remove patch
@@ -12,215 +12,215 @@
 block discarded – undo
12 12
  */
13 13
 class CertificateBundle implements \Countable, \IteratorAggregate
14 14
 {
15
-    /**
16
-     * Certificates.
17
-     *
18
-     * @var Certificate[]
19
-     */
20
-    protected $_certs;
21
-
22
-    /**
23
-     * Mapping from public key id to array of certificates.
24
-     *
25
-     * @var null|(Certificate[])[]
26
-     */
27
-    private $_keyIdMap;
28
-
29
-    /**
30
-     * Constructor.
31
-     *
32
-     * @param Certificate ...$certs Certificate objects
33
-     */
34
-    public function __construct(Certificate ...$certs)
35
-    {
36
-        $this->_certs = $certs;
37
-    }
38
-
39
-    /**
40
-     * Reset internal cached variables on clone.
41
-     */
42
-    public function __clone()
43
-    {
44
-        $this->_keyIdMap = null;
45
-    }
46
-
47
-    /**
48
-     * Initialize from PEMs.
49
-     *
50
-     * @param PEM ...$pems PEM objects
51
-     *
52
-     * @return self
53
-     */
54
-    public static function fromPEMs(PEM ...$pems): self
55
-    {
56
-        $certs = array_map(
57
-            function ($pem) {
58
-                return Certificate::fromPEM($pem);
59
-            }, $pems);
60
-        return new self(...$certs);
61
-    }
62
-
63
-    /**
64
-     * Initialize from PEM bundle.
65
-     *
66
-     * @param PEMBundle $pem_bundle
67
-     *
68
-     * @return self
69
-     */
70
-    public static function fromPEMBundle(PEMBundle $pem_bundle): self
71
-    {
72
-        return self::fromPEMs(...$pem_bundle->all());
73
-    }
74
-
75
-    /**
76
-     * Get self with certificates added.
77
-     *
78
-     * @param Certificate ...$cert
79
-     *
80
-     * @return self
81
-     */
82
-    public function withCertificates(Certificate ...$cert): self
83
-    {
84
-        $obj = clone $this;
85
-        $obj->_certs = array_merge($obj->_certs, $cert);
86
-        return $obj;
87
-    }
88
-
89
-    /**
90
-     * Get self with certificates from PEMBundle added.
91
-     *
92
-     * @param PEMBundle $pem_bundle
93
-     *
94
-     * @return self
95
-     */
96
-    public function withPEMBundle(PEMBundle $pem_bundle): self
97
-    {
98
-        $certs = $this->_certs;
99
-        foreach ($pem_bundle as $pem) {
100
-            $certs[] = Certificate::fromPEM($pem);
101
-        }
102
-        return new self(...$certs);
103
-    }
104
-
105
-    /**
106
-     * Get self with single certificate from PEM added.
107
-     *
108
-     * @param PEM $pem
109
-     *
110
-     * @return self
111
-     */
112
-    public function withPEM(PEM $pem): self
113
-    {
114
-        $certs = $this->_certs;
115
-        $certs[] = Certificate::fromPEM($pem);
116
-        return new self(...$certs);
117
-    }
118
-
119
-    /**
120
-     * Check whether bundle contains a given certificate.
121
-     *
122
-     * @param Certificate $cert
123
-     *
124
-     * @return bool
125
-     */
126
-    public function contains(Certificate $cert): bool
127
-    {
128
-        $id = self::_getCertKeyId($cert);
129
-        $map = $this->_getKeyIdMap();
130
-        if (!isset($map[$id])) {
131
-            return false;
132
-        }
133
-        foreach ($map[$id] as $c) {
134
-            /** @var Certificate $c */
135
-            if ($cert->equals($c)) {
136
-                return true;
137
-            }
138
-        }
139
-        return false;
140
-    }
141
-
142
-    /**
143
-     * Get all certificates that have given subject key identifier.
144
-     *
145
-     * @param string $id
146
-     *
147
-     * @return Certificate[]
148
-     */
149
-    public function allBySubjectKeyIdentifier(string $id): array
150
-    {
151
-        $map = $this->_getKeyIdMap();
152
-        if (!isset($map[$id])) {
153
-            return [];
154
-        }
155
-        return $map[$id];
156
-    }
157
-
158
-    /**
159
-     * Get all certificates in a bundle.
160
-     *
161
-     * @return Certificate[]
162
-     */
163
-    public function all(): array
164
-    {
165
-        return $this->_certs;
166
-    }
167
-
168
-    /**
169
-     * @see \Countable::count()
170
-     *
171
-     * @return int
172
-     */
173
-    public function count(): int
174
-    {
175
-        return count($this->_certs);
176
-    }
177
-
178
-    /**
179
-     * Get iterator for certificates.
180
-     *
181
-     * @see \IteratorAggregate::getIterator()
182
-     *
183
-     * @return \ArrayIterator
184
-     */
185
-    public function getIterator(): \ArrayIterator
186
-    {
187
-        return new \ArrayIterator($this->_certs);
188
-    }
189
-
190
-    /**
191
-     * Get certificate mapping by public key id.
192
-     *
193
-     * @return (Certificate[])[]
194
-     */
195
-    private function _getKeyIdMap(): array
196
-    {
197
-        // lazily build mapping
198
-        if (!isset($this->_keyIdMap)) {
199
-            $this->_keyIdMap = [];
200
-            foreach ($this->_certs as $cert) {
201
-                $id = self::_getCertKeyId($cert);
202
-                if (!isset($this->_keyIdMap[$id])) {
203
-                    $this->_keyIdMap[$id] = [];
204
-                }
205
-                array_push($this->_keyIdMap[$id], $cert);
206
-            }
207
-        }
208
-        return $this->_keyIdMap;
209
-    }
210
-
211
-    /**
212
-     * Get public key id for the certificate.
213
-     *
214
-     * @param Certificate $cert
215
-     *
216
-     * @return string
217
-     */
218
-    private static function _getCertKeyId(Certificate $cert): string
219
-    {
220
-        $exts = $cert->tbsCertificate()->extensions();
221
-        if ($exts->hasSubjectKeyIdentifier()) {
222
-            return $exts->subjectKeyIdentifier()->keyIdentifier();
223
-        }
224
-        return $cert->tbsCertificate()->subjectPublicKeyInfo()->keyIdentifier();
225
-    }
15
+	/**
16
+	 * Certificates.
17
+	 *
18
+	 * @var Certificate[]
19
+	 */
20
+	protected $_certs;
21
+
22
+	/**
23
+	 * Mapping from public key id to array of certificates.
24
+	 *
25
+	 * @var null|(Certificate[])[]
26
+	 */
27
+	private $_keyIdMap;
28
+
29
+	/**
30
+	 * Constructor.
31
+	 *
32
+	 * @param Certificate ...$certs Certificate objects
33
+	 */
34
+	public function __construct(Certificate ...$certs)
35
+	{
36
+		$this->_certs = $certs;
37
+	}
38
+
39
+	/**
40
+	 * Reset internal cached variables on clone.
41
+	 */
42
+	public function __clone()
43
+	{
44
+		$this->_keyIdMap = null;
45
+	}
46
+
47
+	/**
48
+	 * Initialize from PEMs.
49
+	 *
50
+	 * @param PEM ...$pems PEM objects
51
+	 *
52
+	 * @return self
53
+	 */
54
+	public static function fromPEMs(PEM ...$pems): self
55
+	{
56
+		$certs = array_map(
57
+			function ($pem) {
58
+				return Certificate::fromPEM($pem);
59
+			}, $pems);
60
+		return new self(...$certs);
61
+	}
62
+
63
+	/**
64
+	 * Initialize from PEM bundle.
65
+	 *
66
+	 * @param PEMBundle $pem_bundle
67
+	 *
68
+	 * @return self
69
+	 */
70
+	public static function fromPEMBundle(PEMBundle $pem_bundle): self
71
+	{
72
+		return self::fromPEMs(...$pem_bundle->all());
73
+	}
74
+
75
+	/**
76
+	 * Get self with certificates added.
77
+	 *
78
+	 * @param Certificate ...$cert
79
+	 *
80
+	 * @return self
81
+	 */
82
+	public function withCertificates(Certificate ...$cert): self
83
+	{
84
+		$obj = clone $this;
85
+		$obj->_certs = array_merge($obj->_certs, $cert);
86
+		return $obj;
87
+	}
88
+
89
+	/**
90
+	 * Get self with certificates from PEMBundle added.
91
+	 *
92
+	 * @param PEMBundle $pem_bundle
93
+	 *
94
+	 * @return self
95
+	 */
96
+	public function withPEMBundle(PEMBundle $pem_bundle): self
97
+	{
98
+		$certs = $this->_certs;
99
+		foreach ($pem_bundle as $pem) {
100
+			$certs[] = Certificate::fromPEM($pem);
101
+		}
102
+		return new self(...$certs);
103
+	}
104
+
105
+	/**
106
+	 * Get self with single certificate from PEM added.
107
+	 *
108
+	 * @param PEM $pem
109
+	 *
110
+	 * @return self
111
+	 */
112
+	public function withPEM(PEM $pem): self
113
+	{
114
+		$certs = $this->_certs;
115
+		$certs[] = Certificate::fromPEM($pem);
116
+		return new self(...$certs);
117
+	}
118
+
119
+	/**
120
+	 * Check whether bundle contains a given certificate.
121
+	 *
122
+	 * @param Certificate $cert
123
+	 *
124
+	 * @return bool
125
+	 */
126
+	public function contains(Certificate $cert): bool
127
+	{
128
+		$id = self::_getCertKeyId($cert);
129
+		$map = $this->_getKeyIdMap();
130
+		if (!isset($map[$id])) {
131
+			return false;
132
+		}
133
+		foreach ($map[$id] as $c) {
134
+			/** @var Certificate $c */
135
+			if ($cert->equals($c)) {
136
+				return true;
137
+			}
138
+		}
139
+		return false;
140
+	}
141
+
142
+	/**
143
+	 * Get all certificates that have given subject key identifier.
144
+	 *
145
+	 * @param string $id
146
+	 *
147
+	 * @return Certificate[]
148
+	 */
149
+	public function allBySubjectKeyIdentifier(string $id): array
150
+	{
151
+		$map = $this->_getKeyIdMap();
152
+		if (!isset($map[$id])) {
153
+			return [];
154
+		}
155
+		return $map[$id];
156
+	}
157
+
158
+	/**
159
+	 * Get all certificates in a bundle.
160
+	 *
161
+	 * @return Certificate[]
162
+	 */
163
+	public function all(): array
164
+	{
165
+		return $this->_certs;
166
+	}
167
+
168
+	/**
169
+	 * @see \Countable::count()
170
+	 *
171
+	 * @return int
172
+	 */
173
+	public function count(): int
174
+	{
175
+		return count($this->_certs);
176
+	}
177
+
178
+	/**
179
+	 * Get iterator for certificates.
180
+	 *
181
+	 * @see \IteratorAggregate::getIterator()
182
+	 *
183
+	 * @return \ArrayIterator
184
+	 */
185
+	public function getIterator(): \ArrayIterator
186
+	{
187
+		return new \ArrayIterator($this->_certs);
188
+	}
189
+
190
+	/**
191
+	 * Get certificate mapping by public key id.
192
+	 *
193
+	 * @return (Certificate[])[]
194
+	 */
195
+	private function _getKeyIdMap(): array
196
+	{
197
+		// lazily build mapping
198
+		if (!isset($this->_keyIdMap)) {
199
+			$this->_keyIdMap = [];
200
+			foreach ($this->_certs as $cert) {
201
+				$id = self::_getCertKeyId($cert);
202
+				if (!isset($this->_keyIdMap[$id])) {
203
+					$this->_keyIdMap[$id] = [];
204
+				}
205
+				array_push($this->_keyIdMap[$id], $cert);
206
+			}
207
+		}
208
+		return $this->_keyIdMap;
209
+	}
210
+
211
+	/**
212
+	 * Get public key id for the certificate.
213
+	 *
214
+	 * @param Certificate $cert
215
+	 *
216
+	 * @return string
217
+	 */
218
+	private static function _getCertKeyId(Certificate $cert): string
219
+	{
220
+		$exts = $cert->tbsCertificate()->extensions();
221
+		if ($exts->hasSubjectKeyIdentifier()) {
222
+			return $exts->subjectKeyIdentifier()->keyIdentifier();
223
+		}
224
+		return $cert->tbsCertificate()->subjectPublicKeyInfo()->keyIdentifier();
225
+	}
226 226
 }
Please login to merge, or discard this patch.
lib/X509/Certificate/CertificateChain.php 1 patch
Indentation   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -13,136 +13,136 @@
 block discarded – undo
13 13
  */
14 14
 class CertificateChain implements \Countable, \IteratorAggregate
15 15
 {
16
-    /**
17
-     * List of certificates in a chain.
18
-     *
19
-     * @var Certificate[]
20
-     */
21
-    protected $_certs;
16
+	/**
17
+	 * List of certificates in a chain.
18
+	 *
19
+	 * @var Certificate[]
20
+	 */
21
+	protected $_certs;
22 22
 
23
-    /**
24
-     * Constructor.
25
-     *
26
-     * @param Certificate ...$certs List of certificates, end-entity first
27
-     */
28
-    public function __construct(Certificate ...$certs)
29
-    {
30
-        $this->_certs = $certs;
31
-    }
23
+	/**
24
+	 * Constructor.
25
+	 *
26
+	 * @param Certificate ...$certs List of certificates, end-entity first
27
+	 */
28
+	public function __construct(Certificate ...$certs)
29
+	{
30
+		$this->_certs = $certs;
31
+	}
32 32
 
33
-    /**
34
-     * Initialize from a list of PEMs.
35
-     *
36
-     * @param PEM ...$pems
37
-     *
38
-     * @return self
39
-     */
40
-    public static function fromPEMs(PEM ...$pems): self
41
-    {
42
-        $certs = array_map(
43
-            function (PEM $pem) {
44
-                return Certificate::fromPEM($pem);
45
-            }, $pems);
46
-        return new self(...$certs);
47
-    }
33
+	/**
34
+	 * Initialize from a list of PEMs.
35
+	 *
36
+	 * @param PEM ...$pems
37
+	 *
38
+	 * @return self
39
+	 */
40
+	public static function fromPEMs(PEM ...$pems): self
41
+	{
42
+		$certs = array_map(
43
+			function (PEM $pem) {
44
+				return Certificate::fromPEM($pem);
45
+			}, $pems);
46
+		return new self(...$certs);
47
+	}
48 48
 
49
-    /**
50
-     * Initialize from a string containing multiple PEM blocks.
51
-     *
52
-     * @param string $str
53
-     *
54
-     * @return self
55
-     */
56
-    public static function fromPEMString(string $str): self
57
-    {
58
-        $pems = PEMBundle::fromString($str)->all();
59
-        return self::fromPEMs(...$pems);
60
-    }
49
+	/**
50
+	 * Initialize from a string containing multiple PEM blocks.
51
+	 *
52
+	 * @param string $str
53
+	 *
54
+	 * @return self
55
+	 */
56
+	public static function fromPEMString(string $str): self
57
+	{
58
+		$pems = PEMBundle::fromString($str)->all();
59
+		return self::fromPEMs(...$pems);
60
+	}
61 61
 
62
-    /**
63
-     * Get all certificates in a chain ordered from the end-entity certificate
64
-     * to the trust anchor.
65
-     *
66
-     * @return Certificate[]
67
-     */
68
-    public function certificates(): array
69
-    {
70
-        return $this->_certs;
71
-    }
62
+	/**
63
+	 * Get all certificates in a chain ordered from the end-entity certificate
64
+	 * to the trust anchor.
65
+	 *
66
+	 * @return Certificate[]
67
+	 */
68
+	public function certificates(): array
69
+	{
70
+		return $this->_certs;
71
+	}
72 72
 
73
-    /**
74
-     * Get the end-entity certificate.
75
-     *
76
-     * @throws \LogicException
77
-     *
78
-     * @return Certificate
79
-     */
80
-    public function endEntityCertificate(): Certificate
81
-    {
82
-        if (!count($this->_certs)) {
83
-            throw new \LogicException('No certificates.');
84
-        }
85
-        return $this->_certs[0];
86
-    }
73
+	/**
74
+	 * Get the end-entity certificate.
75
+	 *
76
+	 * @throws \LogicException
77
+	 *
78
+	 * @return Certificate
79
+	 */
80
+	public function endEntityCertificate(): Certificate
81
+	{
82
+		if (!count($this->_certs)) {
83
+			throw new \LogicException('No certificates.');
84
+		}
85
+		return $this->_certs[0];
86
+	}
87 87
 
88
-    /**
89
-     * Get the trust anchor certificate.
90
-     *
91
-     * @throws \LogicException
92
-     *
93
-     * @return Certificate
94
-     */
95
-    public function trustAnchorCertificate(): Certificate
96
-    {
97
-        if (!count($this->_certs)) {
98
-            throw new \LogicException('No certificates.');
99
-        }
100
-        return $this->_certs[count($this->_certs) - 1];
101
-    }
88
+	/**
89
+	 * Get the trust anchor certificate.
90
+	 *
91
+	 * @throws \LogicException
92
+	 *
93
+	 * @return Certificate
94
+	 */
95
+	public function trustAnchorCertificate(): Certificate
96
+	{
97
+		if (!count($this->_certs)) {
98
+			throw new \LogicException('No certificates.');
99
+		}
100
+		return $this->_certs[count($this->_certs) - 1];
101
+	}
102 102
 
103
-    /**
104
-     * Convert certificate chain to certification path.
105
-     *
106
-     * @return CertificationPath
107
-     */
108
-    public function certificationPath(): CertificationPath
109
-    {
110
-        return CertificationPath::fromCertificateChain($this);
111
-    }
103
+	/**
104
+	 * Convert certificate chain to certification path.
105
+	 *
106
+	 * @return CertificationPath
107
+	 */
108
+	public function certificationPath(): CertificationPath
109
+	{
110
+		return CertificationPath::fromCertificateChain($this);
111
+	}
112 112
 
113
-    /**
114
-     * Convert certificate chain to string of PEM blocks.
115
-     *
116
-     * @return string
117
-     */
118
-    public function toPEMString(): string
119
-    {
120
-        return implode("\n",
121
-            array_map(
122
-                function (Certificate $cert) {
123
-                    return $cert->toPEM()->string();
124
-                }, $this->_certs));
125
-    }
113
+	/**
114
+	 * Convert certificate chain to string of PEM blocks.
115
+	 *
116
+	 * @return string
117
+	 */
118
+	public function toPEMString(): string
119
+	{
120
+		return implode("\n",
121
+			array_map(
122
+				function (Certificate $cert) {
123
+					return $cert->toPEM()->string();
124
+				}, $this->_certs));
125
+	}
126 126
 
127
-    /**
128
-     * @see \Countable::count()
129
-     *
130
-     * @return int
131
-     */
132
-    public function count(): int
133
-    {
134
-        return count($this->_certs);
135
-    }
127
+	/**
128
+	 * @see \Countable::count()
129
+	 *
130
+	 * @return int
131
+	 */
132
+	public function count(): int
133
+	{
134
+		return count($this->_certs);
135
+	}
136 136
 
137
-    /**
138
-     * Get iterator for certificates.
139
-     *
140
-     * @see \IteratorAggregate::getIterator()
141
-     *
142
-     * @return \ArrayIterator
143
-     */
144
-    public function getIterator(): \ArrayIterator
145
-    {
146
-        return new \ArrayIterator($this->_certs);
147
-    }
137
+	/**
138
+	 * Get iterator for certificates.
139
+	 *
140
+	 * @see \IteratorAggregate::getIterator()
141
+	 *
142
+	 * @return \ArrayIterator
143
+	 */
144
+	public function getIterator(): \ArrayIterator
145
+	{
146
+		return new \ArrayIterator($this->_certs);
147
+	}
148 148
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathBuilding/CertificationPathBuilder.php 1 patch
Indentation   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -16,139 +16,139 @@
 block discarded – undo
16 16
  */
17 17
 class CertificationPathBuilder
18 18
 {
19
-    /**
20
-     * Trust anchors.
21
-     *
22
-     * @var CertificateBundle
23
-     */
24
-    protected $_trustList;
19
+	/**
20
+	 * Trust anchors.
21
+	 *
22
+	 * @var CertificateBundle
23
+	 */
24
+	protected $_trustList;
25 25
 
26
-    /**
27
-     * Constructor.
28
-     *
29
-     * @param CertificateBundle $trust_list List of trust anchors
30
-     */
31
-    public function __construct(CertificateBundle $trust_list)
32
-    {
33
-        $this->_trustList = $trust_list;
34
-    }
26
+	/**
27
+	 * Constructor.
28
+	 *
29
+	 * @param CertificateBundle $trust_list List of trust anchors
30
+	 */
31
+	public function __construct(CertificateBundle $trust_list)
32
+	{
33
+		$this->_trustList = $trust_list;
34
+	}
35 35
 
36
-    /**
37
-     * Get all certification paths to given target certificate from
38
-     * any trust anchor.
39
-     *
40
-     * @param Certificate            $target       Target certificate
41
-     * @param null|CertificateBundle $intermediate Optional intermediate certificates
42
-     *
43
-     * @return CertificationPath[]
44
-     */
45
-    public function allPathsToTarget(Certificate $target,
46
-        ?CertificateBundle $intermediate = null): array
47
-    {
48
-        $paths = $this->_resolvePathsToTarget($target, $intermediate);
49
-        // map paths to CertificationPath objects
50
-        return array_map(
51
-            function ($certs) {
52
-                return new CertificationPath(...$certs);
53
-            }, $paths);
54
-    }
36
+	/**
37
+	 * Get all certification paths to given target certificate from
38
+	 * any trust anchor.
39
+	 *
40
+	 * @param Certificate            $target       Target certificate
41
+	 * @param null|CertificateBundle $intermediate Optional intermediate certificates
42
+	 *
43
+	 * @return CertificationPath[]
44
+	 */
45
+	public function allPathsToTarget(Certificate $target,
46
+		?CertificateBundle $intermediate = null): array
47
+	{
48
+		$paths = $this->_resolvePathsToTarget($target, $intermediate);
49
+		// map paths to CertificationPath objects
50
+		return array_map(
51
+			function ($certs) {
52
+				return new CertificationPath(...$certs);
53
+			}, $paths);
54
+	}
55 55
 
56
-    /**
57
-     * Get shortest path to given target certificate from any trust anchor.
58
-     *
59
-     * @param Certificate            $target       Target certificate
60
-     * @param null|CertificateBundle $intermediate Optional intermediate certificates
61
-     *
62
-     * @throws PathBuildingException
63
-     *
64
-     * @return CertificationPath
65
-     */
66
-    public function shortestPathToTarget(Certificate $target,
67
-        ?CertificateBundle $intermediate = null): CertificationPath
68
-    {
69
-        $paths = $this->allPathsToTarget($target, $intermediate);
70
-        if (!count($paths)) {
71
-            throw new PathBuildingException('No certification paths.');
72
-        }
73
-        usort($paths,
74
-            function ($a, $b) {
75
-                return count($a) < count($b) ? -1 : 1;
76
-            });
77
-        return reset($paths);
78
-    }
56
+	/**
57
+	 * Get shortest path to given target certificate from any trust anchor.
58
+	 *
59
+	 * @param Certificate            $target       Target certificate
60
+	 * @param null|CertificateBundle $intermediate Optional intermediate certificates
61
+	 *
62
+	 * @throws PathBuildingException
63
+	 *
64
+	 * @return CertificationPath
65
+	 */
66
+	public function shortestPathToTarget(Certificate $target,
67
+		?CertificateBundle $intermediate = null): CertificationPath
68
+	{
69
+		$paths = $this->allPathsToTarget($target, $intermediate);
70
+		if (!count($paths)) {
71
+			throw new PathBuildingException('No certification paths.');
72
+		}
73
+		usort($paths,
74
+			function ($a, $b) {
75
+				return count($a) < count($b) ? -1 : 1;
76
+			});
77
+		return reset($paths);
78
+	}
79 79
 
80
-    /**
81
-     * Find all issuers of the target certificate from a given bundle.
82
-     *
83
-     * @param Certificate       $target Target certificate
84
-     * @param CertificateBundle $bundle Certificates to search
85
-     *
86
-     * @return Certificate[]
87
-     */
88
-    protected function _findIssuers(Certificate $target,
89
-        CertificateBundle $bundle): array
90
-    {
91
-        $issuers = [];
92
-        $issuer_name = $target->tbsCertificate()->issuer();
93
-        $extensions = $target->tbsCertificate()->extensions();
94
-        // find by authority key identifier
95
-        if ($extensions->hasAuthorityKeyIdentifier()) {
96
-            $ext = $extensions->authorityKeyIdentifier();
97
-            if ($ext->hasKeyIdentifier()) {
98
-                foreach ($bundle->allBySubjectKeyIdentifier(
99
-                    $ext->keyIdentifier()) as $issuer) {
100
-                    // check that issuer name matches
101
-                    if ($issuer->tbsCertificate()->subject()->equals($issuer_name)) {
102
-                        $issuers[] = $issuer;
103
-                    }
104
-                }
105
-            }
106
-        }
107
-        return $issuers;
108
-    }
80
+	/**
81
+	 * Find all issuers of the target certificate from a given bundle.
82
+	 *
83
+	 * @param Certificate       $target Target certificate
84
+	 * @param CertificateBundle $bundle Certificates to search
85
+	 *
86
+	 * @return Certificate[]
87
+	 */
88
+	protected function _findIssuers(Certificate $target,
89
+		CertificateBundle $bundle): array
90
+	{
91
+		$issuers = [];
92
+		$issuer_name = $target->tbsCertificate()->issuer();
93
+		$extensions = $target->tbsCertificate()->extensions();
94
+		// find by authority key identifier
95
+		if ($extensions->hasAuthorityKeyIdentifier()) {
96
+			$ext = $extensions->authorityKeyIdentifier();
97
+			if ($ext->hasKeyIdentifier()) {
98
+				foreach ($bundle->allBySubjectKeyIdentifier(
99
+					$ext->keyIdentifier()) as $issuer) {
100
+					// check that issuer name matches
101
+					if ($issuer->tbsCertificate()->subject()->equals($issuer_name)) {
102
+						$issuers[] = $issuer;
103
+					}
104
+				}
105
+			}
106
+		}
107
+		return $issuers;
108
+	}
109 109
 
110
-    /**
111
-     * Resolve all possible certification paths from any trust anchor to
112
-     * the target certificate, using optional intermediate certificates.
113
-     *
114
-     * Helper method for allPathsToTarget to be called recursively.
115
-     *
116
-     * @todo Implement loop detection
117
-     *
118
-     * @param Certificate            $target
119
-     * @param null|CertificateBundle $intermediate
120
-     *
121
-     * @return array[] Array of arrays containing path certificates
122
-     */
123
-    private function _resolvePathsToTarget(Certificate $target,
124
-        ?CertificateBundle $intermediate = null): array
125
-    {
126
-        // array of possible paths
127
-        $paths = [];
128
-        // signed by certificate in the trust list
129
-        foreach ($this->_findIssuers($target, $this->_trustList) as $issuer) {
130
-            // if target is self-signed, path consists of only
131
-            // the target certificate
132
-            if ($target->equals($issuer)) {
133
-                $paths[] = [$target];
134
-            } else {
135
-                $paths[] = [$issuer, $target];
136
-            }
137
-        }
138
-        if (isset($intermediate)) {
139
-            // signed by intermediate certificate
140
-            foreach ($this->_findIssuers($target, $intermediate) as $issuer) {
141
-                // intermediate certificate must not be self-signed
142
-                if ($issuer->isSelfIssued()) {
143
-                    continue;
144
-                }
145
-                // resolve paths to issuer
146
-                $subpaths = $this->_resolvePathsToTarget($issuer, $intermediate);
147
-                foreach ($subpaths as $path) {
148
-                    $paths[] = array_merge($path, [$target]);
149
-                }
150
-            }
151
-        }
152
-        return $paths;
153
-    }
110
+	/**
111
+	 * Resolve all possible certification paths from any trust anchor to
112
+	 * the target certificate, using optional intermediate certificates.
113
+	 *
114
+	 * Helper method for allPathsToTarget to be called recursively.
115
+	 *
116
+	 * @todo Implement loop detection
117
+	 *
118
+	 * @param Certificate            $target
119
+	 * @param null|CertificateBundle $intermediate
120
+	 *
121
+	 * @return array[] Array of arrays containing path certificates
122
+	 */
123
+	private function _resolvePathsToTarget(Certificate $target,
124
+		?CertificateBundle $intermediate = null): array
125
+	{
126
+		// array of possible paths
127
+		$paths = [];
128
+		// signed by certificate in the trust list
129
+		foreach ($this->_findIssuers($target, $this->_trustList) as $issuer) {
130
+			// if target is self-signed, path consists of only
131
+			// the target certificate
132
+			if ($target->equals($issuer)) {
133
+				$paths[] = [$target];
134
+			} else {
135
+				$paths[] = [$issuer, $target];
136
+			}
137
+		}
138
+		if (isset($intermediate)) {
139
+			// signed by intermediate certificate
140
+			foreach ($this->_findIssuers($target, $intermediate) as $issuer) {
141
+				// intermediate certificate must not be self-signed
142
+				if ($issuer->isSelfIssued()) {
143
+					continue;
144
+				}
145
+				// resolve paths to issuer
146
+				$subpaths = $this->_resolvePathsToTarget($issuer, $intermediate);
147
+				foreach ($subpaths as $path) {
148
+					$paths[] = array_merge($path, [$target]);
149
+				}
150
+			}
151
+		}
152
+		return $paths;
153
+	}
154 154
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathValidation/ValidatorState.php 1 patch
Indentation   +496 added lines, -496 removed lines patch added patch discarded remove patch
@@ -20,500 +20,500 @@
 block discarded – undo
20 20
  */
21 21
 class ValidatorState
22 22
 {
23
-    /**
24
-     * Length of the certification path (n).
25
-     *
26
-     * @var int
27
-     */
28
-    protected $_pathLength;
29
-
30
-    /**
31
-     * Current index in the certification path in the range of 1..n (i).
32
-     *
33
-     * @var int
34
-     */
35
-    protected $_index;
36
-
37
-    /**
38
-     * Valid policy tree (valid_policy_tree).
39
-     *
40
-     * A tree of certificate policies with their optional qualifiers.
41
-     * Each of the leaves of the tree represents a valid policy at this stage in
42
-     * the certification path validation.
43
-     * Once the tree is set to NULL, policy processing ceases.
44
-     *
45
-     * @var null|PolicyTree
46
-     */
47
-    protected $_validPolicyTree;
48
-
49
-    /**
50
-     * Permitted subtrees (permitted_subtrees).
51
-     *
52
-     * A set of root names for each name type defining a set of subtrees within
53
-     * which all subject names in subsequent certificates in the certification
54
-     * path must fall.
55
-     *
56
-     * @var mixed
57
-     */
58
-    protected $_permittedSubtrees;
59
-
60
-    /**
61
-     * Excluded subtrees (excluded_subtrees).
62
-     *
63
-     * A set of root names for each name type defining a set of subtrees within
64
-     * which no subject name in subsequent certificates in the certification
65
-     * path may fall.
66
-     *
67
-     * @var mixed
68
-     */
69
-    protected $_excludedSubtrees;
70
-
71
-    /**
72
-     * Explicit policy (explicit_policy).
73
-     *
74
-     * An integer that indicates if a non-NULL valid_policy_tree is required.
75
-     *
76
-     * @var int
77
-     */
78
-    protected $_explicitPolicy;
79
-
80
-    /**
81
-     * Inhibit anyPolicy (inhibit_anyPolicy).
82
-     *
83
-     * An integer that indicates whether the anyPolicy policy identifier is
84
-     * considered a match.
85
-     *
86
-     * @var int
87
-     */
88
-    protected $_inhibitAnyPolicy;
89
-
90
-    /**
91
-     * Policy mapping (policy_mapping).
92
-     *
93
-     * An integer that indicates if policy mapping is permitted.
94
-     *
95
-     * @var int
96
-     */
97
-    protected $_policyMapping;
98
-
99
-    /**
100
-     * Working public key algorithm (working_public_key_algorithm).
101
-     *
102
-     * The digital signature algorithm used to verify the signature of a
103
-     * certificate.
104
-     *
105
-     * @var AlgorithmIdentifierType
106
-     */
107
-    protected $_workingPublicKeyAlgorithm;
108
-
109
-    /**
110
-     * Working public key (working_public_key).
111
-     *
112
-     * The public key used to verify the signature of a certificate.
113
-     *
114
-     * @var PublicKeyInfo
115
-     */
116
-    protected $_workingPublicKey;
117
-
118
-    /**
119
-     * Working public key parameters (working_public_key_parameters).
120
-     *
121
-     * Parameters associated with the current public key that may be required to
122
-     * verify a signature.
123
-     *
124
-     * @var null|Element
125
-     */
126
-    protected $_workingPublicKeyParameters;
127
-
128
-    /**
129
-     * Working issuer name (working_issuer_name).
130
-     *
131
-     * The issuer distinguished name expected in the next certificate in the
132
-     * chain.
133
-     *
134
-     * @var Name
135
-     */
136
-    protected $_workingIssuerName;
137
-
138
-    /**
139
-     * Maximum certification path length (max_path_length).
140
-     *
141
-     * @var int
142
-     */
143
-    protected $_maxPathLength;
144
-
145
-    /**
146
-     * Constructor.
147
-     */
148
-    protected function __construct()
149
-    {
150
-    }
151
-
152
-    /**
153
-     * Initialize variables according to RFC 5280 6.1.2.
154
-     *
155
-     * @see https://tools.ietf.org/html/rfc5280#section-6.1.2
156
-     *
157
-     * @param PathValidationConfig $config
158
-     * @param Certificate          $trust_anchor Trust anchor certificate
159
-     * @param int                  $n            Number of certificates
160
-     *                                           in the certification path
161
-     *
162
-     * @return self
163
-     */
164
-    public static function initialize(PathValidationConfig $config,
165
-        Certificate $trust_anchor, int $n): self
166
-    {
167
-        $state = new self();
168
-        $state->_pathLength = $n;
169
-        $state->_index = 1;
170
-        $state->_validPolicyTree = new PolicyTree(PolicyNode::anyPolicyNode());
171
-        $state->_permittedSubtrees = null;
172
-        $state->_excludedSubtrees = null;
173
-        $state->_explicitPolicy = $config->explicitPolicy() ? 0 : $n + 1;
174
-        $state->_inhibitAnyPolicy = $config->anyPolicyInhibit() ? 0 : $n + 1;
175
-        $state->_policyMapping = $config->policyMappingInhibit() ? 0 : $n + 1;
176
-        $state->_workingPublicKeyAlgorithm = $trust_anchor->signatureAlgorithm();
177
-        $tbsCert = $trust_anchor->tbsCertificate();
178
-        $state->_workingPublicKey = $tbsCert->subjectPublicKeyInfo();
179
-        $state->_workingPublicKeyParameters = self::getAlgorithmParameters(
180
-            $state->_workingPublicKey->algorithmIdentifier());
181
-        $state->_workingIssuerName = $tbsCert->issuer();
182
-        $state->_maxPathLength = $config->maxLength();
183
-        return $state;
184
-    }
185
-
186
-    /**
187
-     * Get self with current certification path index set.
188
-     *
189
-     * @param int $index
190
-     *
191
-     * @return self
192
-     */
193
-    public function withIndex(int $index): self
194
-    {
195
-        $state = clone $this;
196
-        $state->_index = $index;
197
-        return $state;
198
-    }
199
-
200
-    /**
201
-     * Get self with valid_policy_tree.
202
-     *
203
-     * @param PolicyTree $policy_tree
204
-     *
205
-     * @return self
206
-     */
207
-    public function withValidPolicyTree(PolicyTree $policy_tree): self
208
-    {
209
-        $state = clone $this;
210
-        $state->_validPolicyTree = $policy_tree;
211
-        return $state;
212
-    }
213
-
214
-    /**
215
-     * Get self with valid_policy_tree set to null.
216
-     *
217
-     * @return self
218
-     */
219
-    public function withoutValidPolicyTree(): self
220
-    {
221
-        $state = clone $this;
222
-        $state->_validPolicyTree = null;
223
-        return $state;
224
-    }
225
-
226
-    /**
227
-     * Get self with explicit_policy.
228
-     *
229
-     * @param int $num
230
-     *
231
-     * @return self
232
-     */
233
-    public function withExplicitPolicy(int $num): self
234
-    {
235
-        $state = clone $this;
236
-        $state->_explicitPolicy = $num;
237
-        return $state;
238
-    }
239
-
240
-    /**
241
-     * Get self with inhibit_anyPolicy.
242
-     *
243
-     * @param int $num
244
-     *
245
-     * @return self
246
-     */
247
-    public function withInhibitAnyPolicy(int $num): self
248
-    {
249
-        $state = clone $this;
250
-        $state->_inhibitAnyPolicy = $num;
251
-        return $state;
252
-    }
253
-
254
-    /**
255
-     * Get self with policy_mapping.
256
-     *
257
-     * @param int $num
258
-     *
259
-     * @return self
260
-     */
261
-    public function withPolicyMapping(int $num): self
262
-    {
263
-        $state = clone $this;
264
-        $state->_policyMapping = $num;
265
-        return $state;
266
-    }
267
-
268
-    /**
269
-     * Get self with working_public_key_algorithm.
270
-     *
271
-     * @param AlgorithmIdentifierType $algo
272
-     *
273
-     * @return self
274
-     */
275
-    public function withWorkingPublicKeyAlgorithm(AlgorithmIdentifierType $algo): self
276
-    {
277
-        $state = clone $this;
278
-        $state->_workingPublicKeyAlgorithm = $algo;
279
-        return $state;
280
-    }
281
-
282
-    /**
283
-     * Get self with working_public_key.
284
-     *
285
-     * @param PublicKeyInfo $pubkey_info
286
-     *
287
-     * @return self
288
-     */
289
-    public function withWorkingPublicKey(PublicKeyInfo $pubkey_info): self
290
-    {
291
-        $state = clone $this;
292
-        $state->_workingPublicKey = $pubkey_info;
293
-        return $state;
294
-    }
295
-
296
-    /**
297
-     * Get self with working_public_key_parameters.
298
-     *
299
-     * @param null|Element $params
300
-     *
301
-     * @return self
302
-     */
303
-    public function withWorkingPublicKeyParameters(?Element $params = null): self
304
-    {
305
-        $state = clone $this;
306
-        $state->_workingPublicKeyParameters = $params;
307
-        return $state;
308
-    }
309
-
310
-    /**
311
-     * Get self with working_issuer_name.
312
-     *
313
-     * @param Name $issuer
314
-     *
315
-     * @return self
316
-     */
317
-    public function withWorkingIssuerName(Name $issuer): self
318
-    {
319
-        $state = clone $this;
320
-        $state->_workingIssuerName = $issuer;
321
-        return $state;
322
-    }
323
-
324
-    /**
325
-     * Get self with max_path_length.
326
-     *
327
-     * @param int $length
328
-     *
329
-     * @return self
330
-     */
331
-    public function withMaxPathLength(int $length): self
332
-    {
333
-        $state = clone $this;
334
-        $state->_maxPathLength = $length;
335
-        return $state;
336
-    }
337
-
338
-    /**
339
-     * Get the certification path length (n).
340
-     *
341
-     * @return int
342
-     */
343
-    public function pathLength(): int
344
-    {
345
-        return $this->_pathLength;
346
-    }
347
-
348
-    /**
349
-     * Get the current index in certification path in the range of 1..n.
350
-     *
351
-     * @return int
352
-     */
353
-    public function index(): int
354
-    {
355
-        return $this->_index;
356
-    }
357
-
358
-    /**
359
-     * Check whether valid_policy_tree is present.
360
-     *
361
-     * @return bool
362
-     */
363
-    public function hasValidPolicyTree(): bool
364
-    {
365
-        return isset($this->_validPolicyTree);
366
-    }
367
-
368
-    /**
369
-     * Get valid_policy_tree.
370
-     *
371
-     * @throws \LogicException If not set
372
-     *
373
-     * @return PolicyTree
374
-     */
375
-    public function validPolicyTree(): PolicyTree
376
-    {
377
-        if (!$this->hasValidPolicyTree()) {
378
-            throw new \LogicException('valid_policy_tree not set.');
379
-        }
380
-        return $this->_validPolicyTree;
381
-    }
382
-
383
-    /**
384
-     * Get permitted_subtrees.
385
-     *
386
-     * @return mixed
387
-     */
388
-    public function permittedSubtrees()
389
-    {
390
-        return $this->_permittedSubtrees;
391
-    }
392
-
393
-    /**
394
-     * Get excluded_subtrees.
395
-     *
396
-     * @return mixed
397
-     */
398
-    public function excludedSubtrees()
399
-    {
400
-        return $this->_excludedSubtrees;
401
-    }
402
-
403
-    /**
404
-     * Get explicit_policy.
405
-     *
406
-     * @return int
407
-     */
408
-    public function explicitPolicy(): int
409
-    {
410
-        return $this->_explicitPolicy;
411
-    }
412
-
413
-    /**
414
-     * Get inhibit_anyPolicy.
415
-     *
416
-     * @return int
417
-     */
418
-    public function inhibitAnyPolicy(): int
419
-    {
420
-        return $this->_inhibitAnyPolicy;
421
-    }
422
-
423
-    /**
424
-     * Get policy_mapping.
425
-     *
426
-     * @return int
427
-     */
428
-    public function policyMapping(): int
429
-    {
430
-        return $this->_policyMapping;
431
-    }
432
-
433
-    /**
434
-     * Get working_public_key_algorithm.
435
-     *
436
-     * @return AlgorithmIdentifierType
437
-     */
438
-    public function workingPublicKeyAlgorithm(): AlgorithmIdentifierType
439
-    {
440
-        return $this->_workingPublicKeyAlgorithm;
441
-    }
442
-
443
-    /**
444
-     * Get working_public_key.
445
-     *
446
-     * @return PublicKeyInfo
447
-     */
448
-    public function workingPublicKey(): PublicKeyInfo
449
-    {
450
-        return $this->_workingPublicKey;
451
-    }
452
-
453
-    /**
454
-     * Get working_public_key_parameters.
455
-     *
456
-     * @return null|Element
457
-     */
458
-    public function workingPublicKeyParameters(): ?Element
459
-    {
460
-        return $this->_workingPublicKeyParameters;
461
-    }
462
-
463
-    /**
464
-     * Get working_issuer_name.
465
-     *
466
-     * @return Name
467
-     */
468
-    public function workingIssuerName(): Name
469
-    {
470
-        return $this->_workingIssuerName;
471
-    }
472
-
473
-    /**
474
-     * Get maximum certification path length.
475
-     *
476
-     * @return int
477
-     */
478
-    public function maxPathLength(): int
479
-    {
480
-        return $this->_maxPathLength;
481
-    }
482
-
483
-    /**
484
-     * Check whether processing the final certificate of the certification path.
485
-     *
486
-     * @return bool
487
-     */
488
-    public function isFinal(): bool
489
-    {
490
-        return $this->_index === $this->_pathLength;
491
-    }
492
-
493
-    /**
494
-     * Get the path validation result.
495
-     *
496
-     * @param Certificate[] $certificates Certificates in a certification path
497
-     *
498
-     * @return PathValidationResult
499
-     */
500
-    public function getResult(array $certificates): PathValidationResult
501
-    {
502
-        return new PathValidationResult($certificates, $this->_validPolicyTree,
503
-            $this->_workingPublicKey, $this->_workingPublicKeyAlgorithm,
504
-            $this->_workingPublicKeyParameters);
505
-    }
506
-
507
-    /**
508
-     * Get ASN.1 parameters from algorithm identifier.
509
-     *
510
-     * @param AlgorithmIdentifierType $algo
511
-     *
512
-     * @return null|Element ASN.1 element or null if parameters are omitted
513
-     */
514
-    public static function getAlgorithmParameters(AlgorithmIdentifierType $algo): ?Element
515
-    {
516
-        $seq = $algo->toASN1();
517
-        return $seq->has(1) ? $seq->at(1)->asElement() : null;
518
-    }
23
+	/**
24
+	 * Length of the certification path (n).
25
+	 *
26
+	 * @var int
27
+	 */
28
+	protected $_pathLength;
29
+
30
+	/**
31
+	 * Current index in the certification path in the range of 1..n (i).
32
+	 *
33
+	 * @var int
34
+	 */
35
+	protected $_index;
36
+
37
+	/**
38
+	 * Valid policy tree (valid_policy_tree).
39
+	 *
40
+	 * A tree of certificate policies with their optional qualifiers.
41
+	 * Each of the leaves of the tree represents a valid policy at this stage in
42
+	 * the certification path validation.
43
+	 * Once the tree is set to NULL, policy processing ceases.
44
+	 *
45
+	 * @var null|PolicyTree
46
+	 */
47
+	protected $_validPolicyTree;
48
+
49
+	/**
50
+	 * Permitted subtrees (permitted_subtrees).
51
+	 *
52
+	 * A set of root names for each name type defining a set of subtrees within
53
+	 * which all subject names in subsequent certificates in the certification
54
+	 * path must fall.
55
+	 *
56
+	 * @var mixed
57
+	 */
58
+	protected $_permittedSubtrees;
59
+
60
+	/**
61
+	 * Excluded subtrees (excluded_subtrees).
62
+	 *
63
+	 * A set of root names for each name type defining a set of subtrees within
64
+	 * which no subject name in subsequent certificates in the certification
65
+	 * path may fall.
66
+	 *
67
+	 * @var mixed
68
+	 */
69
+	protected $_excludedSubtrees;
70
+
71
+	/**
72
+	 * Explicit policy (explicit_policy).
73
+	 *
74
+	 * An integer that indicates if a non-NULL valid_policy_tree is required.
75
+	 *
76
+	 * @var int
77
+	 */
78
+	protected $_explicitPolicy;
79
+
80
+	/**
81
+	 * Inhibit anyPolicy (inhibit_anyPolicy).
82
+	 *
83
+	 * An integer that indicates whether the anyPolicy policy identifier is
84
+	 * considered a match.
85
+	 *
86
+	 * @var int
87
+	 */
88
+	protected $_inhibitAnyPolicy;
89
+
90
+	/**
91
+	 * Policy mapping (policy_mapping).
92
+	 *
93
+	 * An integer that indicates if policy mapping is permitted.
94
+	 *
95
+	 * @var int
96
+	 */
97
+	protected $_policyMapping;
98
+
99
+	/**
100
+	 * Working public key algorithm (working_public_key_algorithm).
101
+	 *
102
+	 * The digital signature algorithm used to verify the signature of a
103
+	 * certificate.
104
+	 *
105
+	 * @var AlgorithmIdentifierType
106
+	 */
107
+	protected $_workingPublicKeyAlgorithm;
108
+
109
+	/**
110
+	 * Working public key (working_public_key).
111
+	 *
112
+	 * The public key used to verify the signature of a certificate.
113
+	 *
114
+	 * @var PublicKeyInfo
115
+	 */
116
+	protected $_workingPublicKey;
117
+
118
+	/**
119
+	 * Working public key parameters (working_public_key_parameters).
120
+	 *
121
+	 * Parameters associated with the current public key that may be required to
122
+	 * verify a signature.
123
+	 *
124
+	 * @var null|Element
125
+	 */
126
+	protected $_workingPublicKeyParameters;
127
+
128
+	/**
129
+	 * Working issuer name (working_issuer_name).
130
+	 *
131
+	 * The issuer distinguished name expected in the next certificate in the
132
+	 * chain.
133
+	 *
134
+	 * @var Name
135
+	 */
136
+	protected $_workingIssuerName;
137
+
138
+	/**
139
+	 * Maximum certification path length (max_path_length).
140
+	 *
141
+	 * @var int
142
+	 */
143
+	protected $_maxPathLength;
144
+
145
+	/**
146
+	 * Constructor.
147
+	 */
148
+	protected function __construct()
149
+	{
150
+	}
151
+
152
+	/**
153
+	 * Initialize variables according to RFC 5280 6.1.2.
154
+	 *
155
+	 * @see https://tools.ietf.org/html/rfc5280#section-6.1.2
156
+	 *
157
+	 * @param PathValidationConfig $config
158
+	 * @param Certificate          $trust_anchor Trust anchor certificate
159
+	 * @param int                  $n            Number of certificates
160
+	 *                                           in the certification path
161
+	 *
162
+	 * @return self
163
+	 */
164
+	public static function initialize(PathValidationConfig $config,
165
+		Certificate $trust_anchor, int $n): self
166
+	{
167
+		$state = new self();
168
+		$state->_pathLength = $n;
169
+		$state->_index = 1;
170
+		$state->_validPolicyTree = new PolicyTree(PolicyNode::anyPolicyNode());
171
+		$state->_permittedSubtrees = null;
172
+		$state->_excludedSubtrees = null;
173
+		$state->_explicitPolicy = $config->explicitPolicy() ? 0 : $n + 1;
174
+		$state->_inhibitAnyPolicy = $config->anyPolicyInhibit() ? 0 : $n + 1;
175
+		$state->_policyMapping = $config->policyMappingInhibit() ? 0 : $n + 1;
176
+		$state->_workingPublicKeyAlgorithm = $trust_anchor->signatureAlgorithm();
177
+		$tbsCert = $trust_anchor->tbsCertificate();
178
+		$state->_workingPublicKey = $tbsCert->subjectPublicKeyInfo();
179
+		$state->_workingPublicKeyParameters = self::getAlgorithmParameters(
180
+			$state->_workingPublicKey->algorithmIdentifier());
181
+		$state->_workingIssuerName = $tbsCert->issuer();
182
+		$state->_maxPathLength = $config->maxLength();
183
+		return $state;
184
+	}
185
+
186
+	/**
187
+	 * Get self with current certification path index set.
188
+	 *
189
+	 * @param int $index
190
+	 *
191
+	 * @return self
192
+	 */
193
+	public function withIndex(int $index): self
194
+	{
195
+		$state = clone $this;
196
+		$state->_index = $index;
197
+		return $state;
198
+	}
199
+
200
+	/**
201
+	 * Get self with valid_policy_tree.
202
+	 *
203
+	 * @param PolicyTree $policy_tree
204
+	 *
205
+	 * @return self
206
+	 */
207
+	public function withValidPolicyTree(PolicyTree $policy_tree): self
208
+	{
209
+		$state = clone $this;
210
+		$state->_validPolicyTree = $policy_tree;
211
+		return $state;
212
+	}
213
+
214
+	/**
215
+	 * Get self with valid_policy_tree set to null.
216
+	 *
217
+	 * @return self
218
+	 */
219
+	public function withoutValidPolicyTree(): self
220
+	{
221
+		$state = clone $this;
222
+		$state->_validPolicyTree = null;
223
+		return $state;
224
+	}
225
+
226
+	/**
227
+	 * Get self with explicit_policy.
228
+	 *
229
+	 * @param int $num
230
+	 *
231
+	 * @return self
232
+	 */
233
+	public function withExplicitPolicy(int $num): self
234
+	{
235
+		$state = clone $this;
236
+		$state->_explicitPolicy = $num;
237
+		return $state;
238
+	}
239
+
240
+	/**
241
+	 * Get self with inhibit_anyPolicy.
242
+	 *
243
+	 * @param int $num
244
+	 *
245
+	 * @return self
246
+	 */
247
+	public function withInhibitAnyPolicy(int $num): self
248
+	{
249
+		$state = clone $this;
250
+		$state->_inhibitAnyPolicy = $num;
251
+		return $state;
252
+	}
253
+
254
+	/**
255
+	 * Get self with policy_mapping.
256
+	 *
257
+	 * @param int $num
258
+	 *
259
+	 * @return self
260
+	 */
261
+	public function withPolicyMapping(int $num): self
262
+	{
263
+		$state = clone $this;
264
+		$state->_policyMapping = $num;
265
+		return $state;
266
+	}
267
+
268
+	/**
269
+	 * Get self with working_public_key_algorithm.
270
+	 *
271
+	 * @param AlgorithmIdentifierType $algo
272
+	 *
273
+	 * @return self
274
+	 */
275
+	public function withWorkingPublicKeyAlgorithm(AlgorithmIdentifierType $algo): self
276
+	{
277
+		$state = clone $this;
278
+		$state->_workingPublicKeyAlgorithm = $algo;
279
+		return $state;
280
+	}
281
+
282
+	/**
283
+	 * Get self with working_public_key.
284
+	 *
285
+	 * @param PublicKeyInfo $pubkey_info
286
+	 *
287
+	 * @return self
288
+	 */
289
+	public function withWorkingPublicKey(PublicKeyInfo $pubkey_info): self
290
+	{
291
+		$state = clone $this;
292
+		$state->_workingPublicKey = $pubkey_info;
293
+		return $state;
294
+	}
295
+
296
+	/**
297
+	 * Get self with working_public_key_parameters.
298
+	 *
299
+	 * @param null|Element $params
300
+	 *
301
+	 * @return self
302
+	 */
303
+	public function withWorkingPublicKeyParameters(?Element $params = null): self
304
+	{
305
+		$state = clone $this;
306
+		$state->_workingPublicKeyParameters = $params;
307
+		return $state;
308
+	}
309
+
310
+	/**
311
+	 * Get self with working_issuer_name.
312
+	 *
313
+	 * @param Name $issuer
314
+	 *
315
+	 * @return self
316
+	 */
317
+	public function withWorkingIssuerName(Name $issuer): self
318
+	{
319
+		$state = clone $this;
320
+		$state->_workingIssuerName = $issuer;
321
+		return $state;
322
+	}
323
+
324
+	/**
325
+	 * Get self with max_path_length.
326
+	 *
327
+	 * @param int $length
328
+	 *
329
+	 * @return self
330
+	 */
331
+	public function withMaxPathLength(int $length): self
332
+	{
333
+		$state = clone $this;
334
+		$state->_maxPathLength = $length;
335
+		return $state;
336
+	}
337
+
338
+	/**
339
+	 * Get the certification path length (n).
340
+	 *
341
+	 * @return int
342
+	 */
343
+	public function pathLength(): int
344
+	{
345
+		return $this->_pathLength;
346
+	}
347
+
348
+	/**
349
+	 * Get the current index in certification path in the range of 1..n.
350
+	 *
351
+	 * @return int
352
+	 */
353
+	public function index(): int
354
+	{
355
+		return $this->_index;
356
+	}
357
+
358
+	/**
359
+	 * Check whether valid_policy_tree is present.
360
+	 *
361
+	 * @return bool
362
+	 */
363
+	public function hasValidPolicyTree(): bool
364
+	{
365
+		return isset($this->_validPolicyTree);
366
+	}
367
+
368
+	/**
369
+	 * Get valid_policy_tree.
370
+	 *
371
+	 * @throws \LogicException If not set
372
+	 *
373
+	 * @return PolicyTree
374
+	 */
375
+	public function validPolicyTree(): PolicyTree
376
+	{
377
+		if (!$this->hasValidPolicyTree()) {
378
+			throw new \LogicException('valid_policy_tree not set.');
379
+		}
380
+		return $this->_validPolicyTree;
381
+	}
382
+
383
+	/**
384
+	 * Get permitted_subtrees.
385
+	 *
386
+	 * @return mixed
387
+	 */
388
+	public function permittedSubtrees()
389
+	{
390
+		return $this->_permittedSubtrees;
391
+	}
392
+
393
+	/**
394
+	 * Get excluded_subtrees.
395
+	 *
396
+	 * @return mixed
397
+	 */
398
+	public function excludedSubtrees()
399
+	{
400
+		return $this->_excludedSubtrees;
401
+	}
402
+
403
+	/**
404
+	 * Get explicit_policy.
405
+	 *
406
+	 * @return int
407
+	 */
408
+	public function explicitPolicy(): int
409
+	{
410
+		return $this->_explicitPolicy;
411
+	}
412
+
413
+	/**
414
+	 * Get inhibit_anyPolicy.
415
+	 *
416
+	 * @return int
417
+	 */
418
+	public function inhibitAnyPolicy(): int
419
+	{
420
+		return $this->_inhibitAnyPolicy;
421
+	}
422
+
423
+	/**
424
+	 * Get policy_mapping.
425
+	 *
426
+	 * @return int
427
+	 */
428
+	public function policyMapping(): int
429
+	{
430
+		return $this->_policyMapping;
431
+	}
432
+
433
+	/**
434
+	 * Get working_public_key_algorithm.
435
+	 *
436
+	 * @return AlgorithmIdentifierType
437
+	 */
438
+	public function workingPublicKeyAlgorithm(): AlgorithmIdentifierType
439
+	{
440
+		return $this->_workingPublicKeyAlgorithm;
441
+	}
442
+
443
+	/**
444
+	 * Get working_public_key.
445
+	 *
446
+	 * @return PublicKeyInfo
447
+	 */
448
+	public function workingPublicKey(): PublicKeyInfo
449
+	{
450
+		return $this->_workingPublicKey;
451
+	}
452
+
453
+	/**
454
+	 * Get working_public_key_parameters.
455
+	 *
456
+	 * @return null|Element
457
+	 */
458
+	public function workingPublicKeyParameters(): ?Element
459
+	{
460
+		return $this->_workingPublicKeyParameters;
461
+	}
462
+
463
+	/**
464
+	 * Get working_issuer_name.
465
+	 *
466
+	 * @return Name
467
+	 */
468
+	public function workingIssuerName(): Name
469
+	{
470
+		return $this->_workingIssuerName;
471
+	}
472
+
473
+	/**
474
+	 * Get maximum certification path length.
475
+	 *
476
+	 * @return int
477
+	 */
478
+	public function maxPathLength(): int
479
+	{
480
+		return $this->_maxPathLength;
481
+	}
482
+
483
+	/**
484
+	 * Check whether processing the final certificate of the certification path.
485
+	 *
486
+	 * @return bool
487
+	 */
488
+	public function isFinal(): bool
489
+	{
490
+		return $this->_index === $this->_pathLength;
491
+	}
492
+
493
+	/**
494
+	 * Get the path validation result.
495
+	 *
496
+	 * @param Certificate[] $certificates Certificates in a certification path
497
+	 *
498
+	 * @return PathValidationResult
499
+	 */
500
+	public function getResult(array $certificates): PathValidationResult
501
+	{
502
+		return new PathValidationResult($certificates, $this->_validPolicyTree,
503
+			$this->_workingPublicKey, $this->_workingPublicKeyAlgorithm,
504
+			$this->_workingPublicKeyParameters);
505
+	}
506
+
507
+	/**
508
+	 * Get ASN.1 parameters from algorithm identifier.
509
+	 *
510
+	 * @param AlgorithmIdentifierType $algo
511
+	 *
512
+	 * @return null|Element ASN.1 element or null if parameters are omitted
513
+	 */
514
+	public static function getAlgorithmParameters(AlgorithmIdentifierType $algo): ?Element
515
+	{
516
+		$seq = $algo->toASN1();
517
+		return $seq->has(1) ? $seq->at(1)->asElement() : null;
518
+	}
519 519
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathValidation/PathValidationResult.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -18,81 +18,81 @@
 block discarded – undo
18 18
  */
19 19
 class PathValidationResult
20 20
 {
21
-    /**
22
-     * Certificates in a certification path.
23
-     *
24
-     * @var Certificate[]
25
-     */
26
-    protected $_certificates;
21
+	/**
22
+	 * Certificates in a certification path.
23
+	 *
24
+	 * @var Certificate[]
25
+	 */
26
+	protected $_certificates;
27 27
 
28
-    /**
29
-     * Valid policy tree.
30
-     *
31
-     * @var null|PolicyTree
32
-     */
33
-    protected $_policyTree;
28
+	/**
29
+	 * Valid policy tree.
30
+	 *
31
+	 * @var null|PolicyTree
32
+	 */
33
+	protected $_policyTree;
34 34
 
35
-    /**
36
-     * End-entity certificate's public key.
37
-     *
38
-     * @var PublicKeyInfo
39
-     */
40
-    protected $_publicKeyInfo;
35
+	/**
36
+	 * End-entity certificate's public key.
37
+	 *
38
+	 * @var PublicKeyInfo
39
+	 */
40
+	protected $_publicKeyInfo;
41 41
 
42
-    /**
43
-     * Public key algorithm.
44
-     *
45
-     * @var AlgorithmIdentifierType
46
-     */
47
-    protected $_publicKeyAlgo;
42
+	/**
43
+	 * Public key algorithm.
44
+	 *
45
+	 * @var AlgorithmIdentifierType
46
+	 */
47
+	protected $_publicKeyAlgo;
48 48
 
49
-    /**
50
-     * Public key parameters.
51
-     *
52
-     * @var null|Element
53
-     */
54
-    protected $_publicKeyParameters;
49
+	/**
50
+	 * Public key parameters.
51
+	 *
52
+	 * @var null|Element
53
+	 */
54
+	protected $_publicKeyParameters;
55 55
 
56
-    /**
57
-     * Constructor.
58
-     *
59
-     * @param Certificate[]           $certificates Certificates in a certification path
60
-     * @param null|PolicyTree         $policy_tree  Valid policy tree
61
-     * @param PublicKeyInfo           $pubkey_info  Public key of the end-entity certificate
62
-     * @param AlgorithmIdentifierType $algo         Public key algorithm of the end-entity certificate
63
-     * @param null|Element            $params       Algorithm parameters
64
-     */
65
-    public function __construct(array $certificates, ?PolicyTree $policy_tree,
66
-        PublicKeyInfo $pubkey_info, AlgorithmIdentifierType $algo,
67
-        ?Element $params = null)
68
-    {
69
-        $this->_certificates = array_values($certificates);
70
-        $this->_policyTree = $policy_tree;
71
-        $this->_publicKeyInfo = $pubkey_info;
72
-        $this->_publicKeyAlgo = $algo;
73
-        $this->_publicKeyParameters = $params;
74
-    }
56
+	/**
57
+	 * Constructor.
58
+	 *
59
+	 * @param Certificate[]           $certificates Certificates in a certification path
60
+	 * @param null|PolicyTree         $policy_tree  Valid policy tree
61
+	 * @param PublicKeyInfo           $pubkey_info  Public key of the end-entity certificate
62
+	 * @param AlgorithmIdentifierType $algo         Public key algorithm of the end-entity certificate
63
+	 * @param null|Element            $params       Algorithm parameters
64
+	 */
65
+	public function __construct(array $certificates, ?PolicyTree $policy_tree,
66
+		PublicKeyInfo $pubkey_info, AlgorithmIdentifierType $algo,
67
+		?Element $params = null)
68
+	{
69
+		$this->_certificates = array_values($certificates);
70
+		$this->_policyTree = $policy_tree;
71
+		$this->_publicKeyInfo = $pubkey_info;
72
+		$this->_publicKeyAlgo = $algo;
73
+		$this->_publicKeyParameters = $params;
74
+	}
75 75
 
76
-    /**
77
-     * Get end-entity certificate.
78
-     *
79
-     * @return Certificate
80
-     */
81
-    public function certificate(): Certificate
82
-    {
83
-        return $this->_certificates[count($this->_certificates) - 1];
84
-    }
76
+	/**
77
+	 * Get end-entity certificate.
78
+	 *
79
+	 * @return Certificate
80
+	 */
81
+	public function certificate(): Certificate
82
+	{
83
+		return $this->_certificates[count($this->_certificates) - 1];
84
+	}
85 85
 
86
-    /**
87
-     * Get certificate policies of the end-entity certificate.
88
-     *
89
-     * @return PolicyInformation[]
90
-     */
91
-    public function policies(): array
92
-    {
93
-        if (!$this->_policyTree) {
94
-            return [];
95
-        }
96
-        return $this->_policyTree->policiesAtDepth(count($this->_certificates));
97
-    }
86
+	/**
87
+	 * Get certificate policies of the end-entity certificate.
88
+	 *
89
+	 * @return PolicyInformation[]
90
+	 */
91
+	public function policies(): array
92
+	{
93
+		if (!$this->_policyTree) {
94
+			return [];
95
+		}
96
+		return $this->_policyTree->policiesAtDepth(count($this->_certificates));
97
+	}
98 98
 }
Please login to merge, or discard this patch.
lib/X509/CertificationPath/PathValidation/PathValidationConfig.php 1 patch
Indentation   +253 added lines, -253 removed lines patch added patch discarded remove patch
@@ -14,282 +14,282 @@
 block discarded – undo
14 14
  */
15 15
 class PathValidationConfig
16 16
 {
17
-    /**
18
-     * Maximum allowed certification path length.
19
-     *
20
-     * @var int
21
-     */
22
-    protected $_maxLength;
17
+	/**
18
+	 * Maximum allowed certification path length.
19
+	 *
20
+	 * @var int
21
+	 */
22
+	protected $_maxLength;
23 23
 
24
-    /**
25
-     * Reference time.
26
-     *
27
-     * @var \DateTimeImmutable
28
-     */
29
-    protected $_dateTime;
24
+	/**
25
+	 * Reference time.
26
+	 *
27
+	 * @var \DateTimeImmutable
28
+	 */
29
+	protected $_dateTime;
30 30
 
31
-    /**
32
-     * List of acceptable policy identifiers.
33
-     *
34
-     * @var string[]
35
-     */
36
-    protected $_policySet;
31
+	/**
32
+	 * List of acceptable policy identifiers.
33
+	 *
34
+	 * @var string[]
35
+	 */
36
+	protected $_policySet;
37 37
 
38
-    /**
39
-     * Trust anchor certificate.
40
-     *
41
-     * If not set, path validation uses the first certificate of the path.
42
-     *
43
-     * @var null|Certificate
44
-     */
45
-    protected $_trustAnchor;
38
+	/**
39
+	 * Trust anchor certificate.
40
+	 *
41
+	 * If not set, path validation uses the first certificate of the path.
42
+	 *
43
+	 * @var null|Certificate
44
+	 */
45
+	protected $_trustAnchor;
46 46
 
47
-    /**
48
-     * Whether policy mapping in inhibited.
49
-     *
50
-     * Setting this to true disallows policy mapping.
51
-     *
52
-     * @var bool
53
-     */
54
-    protected $_policyMappingInhibit;
47
+	/**
48
+	 * Whether policy mapping in inhibited.
49
+	 *
50
+	 * Setting this to true disallows policy mapping.
51
+	 *
52
+	 * @var bool
53
+	 */
54
+	protected $_policyMappingInhibit;
55 55
 
56
-    /**
57
-     * Whether the path must be valid for at least one policy in the
58
-     * initial policy set.
59
-     *
60
-     * @var bool
61
-     */
62
-    protected $_explicitPolicy;
56
+	/**
57
+	 * Whether the path must be valid for at least one policy in the
58
+	 * initial policy set.
59
+	 *
60
+	 * @var bool
61
+	 */
62
+	protected $_explicitPolicy;
63 63
 
64
-    /**
65
-     * Whether anyPolicy OID processing should be inhibited.
66
-     *
67
-     * Setting this to true disallows the usage of anyPolicy.
68
-     *
69
-     * @var bool
70
-     */
71
-    protected $_anyPolicyInhibit;
64
+	/**
65
+	 * Whether anyPolicy OID processing should be inhibited.
66
+	 *
67
+	 * Setting this to true disallows the usage of anyPolicy.
68
+	 *
69
+	 * @var bool
70
+	 */
71
+	protected $_anyPolicyInhibit;
72 72
 
73
-    /**
74
-     * @todo Implement
75
-     *
76
-     * @var mixed
77
-     */
78
-    protected $_permittedSubtrees;
73
+	/**
74
+	 * @todo Implement
75
+	 *
76
+	 * @var mixed
77
+	 */
78
+	protected $_permittedSubtrees;
79 79
 
80
-    /**
81
-     * @todo Implement
82
-     *
83
-     * @var mixed
84
-     */
85
-    protected $_excludedSubtrees;
80
+	/**
81
+	 * @todo Implement
82
+	 *
83
+	 * @var mixed
84
+	 */
85
+	protected $_excludedSubtrees;
86 86
 
87
-    /**
88
-     * Constructor.
89
-     *
90
-     * @param \DateTimeImmutable $dt         Reference date and time
91
-     * @param int                $max_length Maximum certification path length
92
-     */
93
-    public function __construct(\DateTimeImmutable $dt, int $max_length)
94
-    {
95
-        $this->_dateTime = $dt;
96
-        $this->_maxLength = $max_length;
97
-        $this->_policySet = [PolicyInformation::OID_ANY_POLICY];
98
-        $this->_policyMappingInhibit = false;
99
-        $this->_explicitPolicy = false;
100
-        $this->_anyPolicyInhibit = false;
101
-    }
87
+	/**
88
+	 * Constructor.
89
+	 *
90
+	 * @param \DateTimeImmutable $dt         Reference date and time
91
+	 * @param int                $max_length Maximum certification path length
92
+	 */
93
+	public function __construct(\DateTimeImmutable $dt, int $max_length)
94
+	{
95
+		$this->_dateTime = $dt;
96
+		$this->_maxLength = $max_length;
97
+		$this->_policySet = [PolicyInformation::OID_ANY_POLICY];
98
+		$this->_policyMappingInhibit = false;
99
+		$this->_explicitPolicy = false;
100
+		$this->_anyPolicyInhibit = false;
101
+	}
102 102
 
103
-    /**
104
-     * Get default configuration.
105
-     *
106
-     * @return self
107
-     */
108
-    public static function defaultConfig(): self
109
-    {
110
-        return new self(new \DateTimeImmutable(), 3);
111
-    }
103
+	/**
104
+	 * Get default configuration.
105
+	 *
106
+	 * @return self
107
+	 */
108
+	public static function defaultConfig(): self
109
+	{
110
+		return new self(new \DateTimeImmutable(), 3);
111
+	}
112 112
 
113
-    /**
114
-     * Get self with maximum path length.
115
-     *
116
-     * @param int $length
117
-     *
118
-     * @return self
119
-     */
120
-    public function withMaxLength(int $length): self
121
-    {
122
-        $obj = clone $this;
123
-        $obj->_maxLength = $length;
124
-        return $obj;
125
-    }
113
+	/**
114
+	 * Get self with maximum path length.
115
+	 *
116
+	 * @param int $length
117
+	 *
118
+	 * @return self
119
+	 */
120
+	public function withMaxLength(int $length): self
121
+	{
122
+		$obj = clone $this;
123
+		$obj->_maxLength = $length;
124
+		return $obj;
125
+	}
126 126
 
127
-    /**
128
-     * Get self with reference date and time.
129
-     *
130
-     * @param \DateTimeImmutable $dt
131
-     *
132
-     * @return self
133
-     */
134
-    public function withDateTime(\DateTimeImmutable $dt): self
135
-    {
136
-        $obj = clone $this;
137
-        $obj->_dateTime = $dt;
138
-        return $obj;
139
-    }
127
+	/**
128
+	 * Get self with reference date and time.
129
+	 *
130
+	 * @param \DateTimeImmutable $dt
131
+	 *
132
+	 * @return self
133
+	 */
134
+	public function withDateTime(\DateTimeImmutable $dt): self
135
+	{
136
+		$obj = clone $this;
137
+		$obj->_dateTime = $dt;
138
+		return $obj;
139
+	}
140 140
 
141
-    /**
142
-     * Get self with trust anchor certificate.
143
-     *
144
-     * @param Certificate $ca
145
-     *
146
-     * @return self
147
-     */
148
-    public function withTrustAnchor(Certificate $ca): self
149
-    {
150
-        $obj = clone $this;
151
-        $obj->_trustAnchor = $ca;
152
-        return $obj;
153
-    }
141
+	/**
142
+	 * Get self with trust anchor certificate.
143
+	 *
144
+	 * @param Certificate $ca
145
+	 *
146
+	 * @return self
147
+	 */
148
+	public function withTrustAnchor(Certificate $ca): self
149
+	{
150
+		$obj = clone $this;
151
+		$obj->_trustAnchor = $ca;
152
+		return $obj;
153
+	}
154 154
 
155
-    /**
156
-     * Get self with initial-policy-mapping-inhibit set.
157
-     *
158
-     * @param bool $flag
159
-     *
160
-     * @return self
161
-     */
162
-    public function withPolicyMappingInhibit(bool $flag): self
163
-    {
164
-        $obj = clone $this;
165
-        $obj->_policyMappingInhibit = $flag;
166
-        return $obj;
167
-    }
155
+	/**
156
+	 * Get self with initial-policy-mapping-inhibit set.
157
+	 *
158
+	 * @param bool $flag
159
+	 *
160
+	 * @return self
161
+	 */
162
+	public function withPolicyMappingInhibit(bool $flag): self
163
+	{
164
+		$obj = clone $this;
165
+		$obj->_policyMappingInhibit = $flag;
166
+		return $obj;
167
+	}
168 168
 
169
-    /**
170
-     * Get self with initial-explicit-policy set.
171
-     *
172
-     * @param bool $flag
173
-     *
174
-     * @return self
175
-     */
176
-    public function withExplicitPolicy(bool $flag): self
177
-    {
178
-        $obj = clone $this;
179
-        $obj->_explicitPolicy = $flag;
180
-        return $obj;
181
-    }
169
+	/**
170
+	 * Get self with initial-explicit-policy set.
171
+	 *
172
+	 * @param bool $flag
173
+	 *
174
+	 * @return self
175
+	 */
176
+	public function withExplicitPolicy(bool $flag): self
177
+	{
178
+		$obj = clone $this;
179
+		$obj->_explicitPolicy = $flag;
180
+		return $obj;
181
+	}
182 182
 
183
-    /**
184
-     * Get self with initial-any-policy-inhibit set.
185
-     *
186
-     * @param bool $flag
187
-     *
188
-     * @return self
189
-     */
190
-    public function withAnyPolicyInhibit(bool $flag): self
191
-    {
192
-        $obj = clone $this;
193
-        $obj->_anyPolicyInhibit = $flag;
194
-        return $obj;
195
-    }
183
+	/**
184
+	 * Get self with initial-any-policy-inhibit set.
185
+	 *
186
+	 * @param bool $flag
187
+	 *
188
+	 * @return self
189
+	 */
190
+	public function withAnyPolicyInhibit(bool $flag): self
191
+	{
192
+		$obj = clone $this;
193
+		$obj->_anyPolicyInhibit = $flag;
194
+		return $obj;
195
+	}
196 196
 
197
-    /**
198
-     * Get self with user-initial-policy-set set to policy OIDs.
199
-     *
200
-     * @param string ...$policies List of policy OIDs
201
-     *
202
-     * @return self
203
-     */
204
-    public function withPolicySet(string ...$policies): self
205
-    {
206
-        $obj = clone $this;
207
-        $obj->_policySet = $policies;
208
-        return $obj;
209
-    }
197
+	/**
198
+	 * Get self with user-initial-policy-set set to policy OIDs.
199
+	 *
200
+	 * @param string ...$policies List of policy OIDs
201
+	 *
202
+	 * @return self
203
+	 */
204
+	public function withPolicySet(string ...$policies): self
205
+	{
206
+		$obj = clone $this;
207
+		$obj->_policySet = $policies;
208
+		return $obj;
209
+	}
210 210
 
211
-    /**
212
-     * Get maximum certification path length.
213
-     *
214
-     * @return int
215
-     */
216
-    public function maxLength(): int
217
-    {
218
-        return $this->_maxLength;
219
-    }
211
+	/**
212
+	 * Get maximum certification path length.
213
+	 *
214
+	 * @return int
215
+	 */
216
+	public function maxLength(): int
217
+	{
218
+		return $this->_maxLength;
219
+	}
220 220
 
221
-    /**
222
-     * Get reference date and time.
223
-     *
224
-     * @return \DateTimeImmutable
225
-     */
226
-    public function dateTime(): \DateTimeImmutable
227
-    {
228
-        return $this->_dateTime;
229
-    }
221
+	/**
222
+	 * Get reference date and time.
223
+	 *
224
+	 * @return \DateTimeImmutable
225
+	 */
226
+	public function dateTime(): \DateTimeImmutable
227
+	{
228
+		return $this->_dateTime;
229
+	}
230 230
 
231
-    /**
232
-     * Get user-initial-policy-set.
233
-     *
234
-     * @return string[] Array of OID's
235
-     */
236
-    public function policySet(): array
237
-    {
238
-        return $this->_policySet;
239
-    }
231
+	/**
232
+	 * Get user-initial-policy-set.
233
+	 *
234
+	 * @return string[] Array of OID's
235
+	 */
236
+	public function policySet(): array
237
+	{
238
+		return $this->_policySet;
239
+	}
240 240
 
241
-    /**
242
-     * Check whether trust anchor certificate is set.
243
-     *
244
-     * @return bool
245
-     */
246
-    public function hasTrustAnchor(): bool
247
-    {
248
-        return isset($this->_trustAnchor);
249
-    }
241
+	/**
242
+	 * Check whether trust anchor certificate is set.
243
+	 *
244
+	 * @return bool
245
+	 */
246
+	public function hasTrustAnchor(): bool
247
+	{
248
+		return isset($this->_trustAnchor);
249
+	}
250 250
 
251
-    /**
252
-     * Get trust anchor certificate.
253
-     *
254
-     * @throws \LogicException If not set
255
-     *
256
-     * @return Certificate
257
-     */
258
-    public function trustAnchor(): Certificate
259
-    {
260
-        if (!$this->hasTrustAnchor()) {
261
-            throw new \LogicException('No trust anchor.');
262
-        }
263
-        return $this->_trustAnchor;
264
-    }
251
+	/**
252
+	 * Get trust anchor certificate.
253
+	 *
254
+	 * @throws \LogicException If not set
255
+	 *
256
+	 * @return Certificate
257
+	 */
258
+	public function trustAnchor(): Certificate
259
+	{
260
+		if (!$this->hasTrustAnchor()) {
261
+			throw new \LogicException('No trust anchor.');
262
+		}
263
+		return $this->_trustAnchor;
264
+	}
265 265
 
266
-    /**
267
-     * Get initial-policy-mapping-inhibit.
268
-     *
269
-     * @return bool
270
-     */
271
-    public function policyMappingInhibit(): bool
272
-    {
273
-        return $this->_policyMappingInhibit;
274
-    }
266
+	/**
267
+	 * Get initial-policy-mapping-inhibit.
268
+	 *
269
+	 * @return bool
270
+	 */
271
+	public function policyMappingInhibit(): bool
272
+	{
273
+		return $this->_policyMappingInhibit;
274
+	}
275 275
 
276
-    /**
277
-     * Get initial-explicit-policy.
278
-     *
279
-     * @return bool
280
-     */
281
-    public function explicitPolicy(): bool
282
-    {
283
-        return $this->_explicitPolicy;
284
-    }
276
+	/**
277
+	 * Get initial-explicit-policy.
278
+	 *
279
+	 * @return bool
280
+	 */
281
+	public function explicitPolicy(): bool
282
+	{
283
+		return $this->_explicitPolicy;
284
+	}
285 285
 
286
-    /**
287
-     * Get initial-any-policy-inhibit.
288
-     *
289
-     * @return bool
290
-     */
291
-    public function anyPolicyInhibit(): bool
292
-    {
293
-        return $this->_anyPolicyInhibit;
294
-    }
286
+	/**
287
+	 * Get initial-any-policy-inhibit.
288
+	 *
289
+	 * @return bool
290
+	 */
291
+	public function anyPolicyInhibit(): bool
292
+	{
293
+		return $this->_anyPolicyInhibit;
294
+	}
295 295
 }
Please login to merge, or discard this patch.