|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* ***************************************************************************** |
|
5
|
|
|
* Contributions to this work were made on behalf of the GÉANT project, a |
|
6
|
|
|
* project that has received funding from the European Union’s Framework |
|
7
|
|
|
* Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
|
8
|
|
|
* Horizon 2020 research and innovation programme under Grant Agreements No. |
|
9
|
|
|
* 691567 (GN4-1) and No. 731122 (GN4-2). |
|
10
|
|
|
* On behalf of the aforementioned projects, GEANT Association is the sole owner |
|
11
|
|
|
* of the copyright in all material which was developed by a member of the GÉANT |
|
12
|
|
|
* project. GÉANT Vereniging (Association) is registered with the Chamber of |
|
13
|
|
|
* Commerce in Amsterdam with registration number 40535155 and operates in the |
|
14
|
|
|
* UK as a branch of GÉANT Vereniging. |
|
15
|
|
|
* |
|
16
|
|
|
* Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
|
17
|
|
|
* UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
|
18
|
|
|
* |
|
19
|
|
|
* License: see the web/copyright.inc.php file in the file structure or |
|
20
|
|
|
* <base_url>/copyright.php after deploying the software |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* This file contains code for testing presenting tests result |
|
25
|
|
|
* |
|
26
|
|
|
* @author Maja Gorecka-Wolniewicz <[email protected]> |
|
27
|
|
|
* |
|
28
|
|
|
* @package Developer |
|
29
|
|
|
* |
|
30
|
|
|
*/ |
|
31
|
|
|
|
|
32
|
|
|
namespace core\diag; |
|
33
|
|
|
|
|
34
|
|
|
use \Exception; |
|
35
|
|
|
|
|
36
|
|
|
class RADIUSTestsUI extends AbstractTest |
|
37
|
|
|
{ |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* This private variable contains the realm to be checked. Is filled in the |
|
41
|
|
|
* class constructor. |
|
42
|
|
|
* |
|
43
|
|
|
* @var string |
|
44
|
|
|
*/ |
|
45
|
|
|
public $realm = NULL; |
|
46
|
|
|
|
|
47
|
|
|
/** |
|
48
|
|
|
* result of the reachability tests |
|
49
|
|
|
* |
|
50
|
|
|
* @var array |
|
51
|
|
|
*/ |
|
52
|
|
|
public $allReachabilityResults = []; |
|
53
|
|
|
|
|
54
|
|
|
private $hostMap = []; |
|
55
|
|
|
private $globalLevelStatic = \core\common\Entity::L_OK; |
|
56
|
|
|
private $globalLevelDynamic = \core\common\Entity::L_OK; |
|
57
|
|
|
private $rfc7585suite = NULL; |
|
58
|
|
|
private $srv; |
|
59
|
|
|
private $naptr; |
|
60
|
|
|
private $naptrValid; |
|
61
|
|
|
private $hosts; |
|
62
|
|
|
private $testSuite; |
|
63
|
|
|
private $areFailed = FALSE; |
|
64
|
|
|
private $globalInfo = []; |
|
65
|
|
|
private $stateIcons = []; |
|
66
|
|
|
private $states; |
|
67
|
|
|
private $timestamp; |
|
68
|
|
|
const RADIUS_TEST_OPERATION_MODE_SHALLOW = 1; |
|
69
|
|
|
const RADIUS_TEST_OPERATION_MODE_THOROUGH = 2; |
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Constructor for the RADIUSTestsUI class. The single mandatory parameter is the |
|
75
|
|
|
* token indicating tests that were carried out and saved as JSON files. |
|
76
|
|
|
* |
|
77
|
|
|
* @param string $token the token which points to a directory |
|
78
|
|
|
* @throws Exception |
|
79
|
|
|
*/ |
|
80
|
|
|
public function __construct($token) |
|
81
|
|
|
{ |
|
82
|
|
|
parent::__construct(); |
|
83
|
|
|
$this->globalInfo = [ |
|
84
|
|
|
\core\common\Entity::L_OK => _("All tests passed."), |
|
85
|
|
|
\core\common\Entity::L_WARN => _("There were some warnings."), |
|
86
|
|
|
\core\common\Entity::L_ERROR => _("There were some errors."), |
|
87
|
|
|
\core\common\Entity::L_REMARK => _("There were some remarks.") |
|
88
|
|
|
]; |
|
89
|
|
|
$this->stateIcons = [ |
|
90
|
|
|
\core\common\Entity::L_OK => '../resources/images/icons/Quetto/check-icon.png', |
|
91
|
|
|
\core\common\Entity::L_WARN => '../resources/images/icons/Quetto/danger-icon.png', |
|
92
|
|
|
\core\common\Entity::L_ERROR => '../resources/images/icons/Quetto/no-icon.png', |
|
93
|
|
|
\core\common\Entity::L_REMARK => '../resources/images/icons/Quetto/info-icon.png' |
|
94
|
|
|
]; |
|
95
|
|
|
$this->states = [ |
|
96
|
|
|
'PASS' => _("PASS"), |
|
97
|
|
|
'FAIL' => _("FAIL") |
|
98
|
|
|
]; |
|
99
|
|
|
$this->certFields = [ |
|
|
|
|
|
|
100
|
|
|
'subject' => _("Subject:"), |
|
101
|
|
|
'issuer' => _("Issuer:"), |
|
102
|
|
|
'validFrom' => _("Valid from:"), |
|
103
|
|
|
'validTo' => _("Valid to:"), |
|
104
|
|
|
'serialNumber' => _("Serial number:"), |
|
105
|
|
|
'sha1' => _("SHA1 fingerprint:"), |
|
106
|
|
|
'title' => _("Server certificate"), |
|
107
|
|
|
'c_subject' => _("Subject"), |
|
108
|
|
|
'c_issuer' => _("Issuer"), |
|
109
|
|
|
'policies' => _("Policies"), |
|
110
|
|
|
'crldistributionpoints' => _("crlDistributionPoint"), |
|
111
|
|
|
'authorityinfoaccess' => _("authorityInfoAccess"), |
|
112
|
|
|
'subjectaltname' => _("SubjectAltName"), |
|
113
|
|
|
]; |
|
114
|
|
|
$jsondir = dirname(dirname(dirname(__FILE__))) . "/var/json_cache"; |
|
115
|
|
|
if ($token && is_dir($jsondir . '/' . $token)) { |
|
116
|
|
|
foreach (['realm', 'udp', 'clients', 'capath'] as $test_type) { |
|
117
|
|
|
foreach (glob("$jsondir/$token/$test_type*") as $filename) { |
|
118
|
|
|
$this->loggerInstance->debug(4, "\nIS_DIR $filename\n"); |
|
119
|
|
|
if (!array_key_exists($test_type, $this->allReachabilityResults)) { |
|
120
|
|
|
$this->allReachabilityResults[$test_type] = array(); |
|
121
|
|
|
} |
|
122
|
|
|
$this->allReachabilityResults[$test_type][] = json_decode(file_get_contents($filename)); |
|
123
|
|
|
} |
|
124
|
|
|
} |
|
125
|
|
|
if ($this->allReachabilityResults['realm'][0]->realm) { |
|
126
|
|
|
$this->realm = $this->allReachabilityResults['realm'][0]->realm; |
|
127
|
|
|
foreach ($this->allReachabilityResults['realm'][0]->totest as $totest) { |
|
128
|
|
|
$this->hostMap[$totest->host] = $totest->bracketaddr; |
|
129
|
|
|
} |
|
130
|
|
|
$this->rfc7585suite = unserialize($this->allReachabilityResults['realm'][0]->rfc7585suite); |
|
131
|
|
|
$this->srv = $this->allReachabilityResults['realm'][0]->srv; |
|
132
|
|
|
$this->naptr = $this->allReachabilityResults['realm'][0]->naptr; |
|
133
|
|
|
$this->naptrValid= $this->allReachabilityResults['realm'][0]->naptr_valid; |
|
134
|
|
|
$this->hosts = $this->allReachabilityResults['realm'][0]->hosts; |
|
135
|
|
|
$this->testSuite = unserialize($this->allReachabilityResults['realm'][0]->testsuite); |
|
136
|
|
|
} |
|
137
|
|
|
$this->timestamp = $this->allReachabilityResults['realm'][0]->datetime; |
|
138
|
|
|
//print '<pre>'; print_r($this->allReachabilityResults['realm'][0]); print '</pre>'; exit; |
|
139
|
|
|
} |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function getTimeStamp() |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->timestamp; |
|
145
|
|
|
} |
|
146
|
|
|
/** |
|
147
|
|
|
* sets the global status for static tests |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setGlobalStaticResult() |
|
150
|
|
|
{ |
|
151
|
|
|
foreach ($this->allReachabilityResults['udp'] as $udp) { |
|
152
|
|
|
$this->globalLevelStatic = max($this->globalLevelStatic, $udp->result[0]->level); |
|
153
|
|
|
} |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
|
|
public function setGlobalDynamicResult() |
|
157
|
|
|
{ |
|
158
|
|
|
foreach ($this->allReachabilityResults['capath'] as $capath) { |
|
159
|
|
|
$this->globalLevelDynamic = max($this->globalLevelDynamic, $capath->level); |
|
160
|
|
|
} |
|
161
|
|
|
foreach ($this->allReachabilityResults['clients'] as $clients) { |
|
162
|
|
|
$srefused = FALSE; |
|
163
|
|
|
foreach ($clients->ca as $ca) { |
|
164
|
|
|
foreach ($ca->certificate as $certificate) { |
|
165
|
|
|
if ($certificate->returncode == \core\diag\RADIUSTests::RETVAL_CONNECTION_REFUSED) { |
|
166
|
|
|
$srefused = $this->areFailed = TRUE; |
|
167
|
|
|
} |
|
168
|
|
|
} |
|
169
|
|
|
if (!$srefused) { |
|
170
|
|
|
foreach ($clients->ca as $ca) { |
|
|
|
|
|
|
171
|
|
|
foreach ($ca->certificate as $certificate) { |
|
172
|
|
|
$level = $certificate->returncode; |
|
173
|
|
|
if ($level < 0) { |
|
174
|
|
|
$level = \core\common\Entity::L_ERROR; |
|
175
|
|
|
$this->areFailed = TRUE; |
|
176
|
|
|
} |
|
177
|
|
|
if ($certificate->expected != 'PASS') { |
|
178
|
|
|
if ($certificate->connected == 1) { |
|
179
|
|
|
$level = \core\common\Entity::L_WARN; |
|
180
|
|
|
} else { |
|
181
|
|
|
$level = \core\common\Entity::L_OK; |
|
182
|
|
|
} |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
} |
|
186
|
|
|
} |
|
187
|
|
|
} |
|
188
|
|
|
$this->globalLevelDynamic = max($this->globalLevelDynamic, $level); |
|
|
|
|
|
|
189
|
|
|
} |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
public function isDynamic () |
|
193
|
|
|
{ |
|
194
|
|
|
if ($this->naptr> 0) { |
|
195
|
|
|
return TRUE; |
|
196
|
|
|
} |
|
197
|
|
|
return FALSE; |
|
198
|
|
|
} |
|
199
|
|
|
/** |
|
200
|
|
|
* prints tabs-1 |
|
201
|
|
|
* |
|
202
|
|
|
* |
|
203
|
|
|
*/ |
|
204
|
|
|
public function printOverview () |
|
205
|
|
|
{ |
|
206
|
|
|
$out = []; |
|
207
|
|
|
$out[] = "<fieldset class='option_container'> |
|
208
|
|
|
<legend> |
|
209
|
|
|
<strong>" . _("Overview") . '</strong> |
|
210
|
|
|
</legend>'; |
|
211
|
|
|
$out[] = "<strong>" . _("DNS chekcs") . "</strong><div>"; |
|
212
|
|
|
if ($this->naptr != \core\diag\RADIUSTests::RETVAL_NOTCONFIGURED) { |
|
213
|
|
|
$out[] = "<table>"; |
|
214
|
|
|
$out[] = "<tr><td>" . _("Checking NAPTR existence:") . "</td><td>"; |
|
215
|
|
|
switch ($this->naptr) { |
|
216
|
|
|
case \core\diag\RFC7585Tests::RETVAL_NONAPTR: |
|
217
|
|
|
$out[] = _("This realm has no NAPTR records."); |
|
218
|
|
|
break; |
|
219
|
|
|
case \core\diag\RFC7585Tests::RETVAL_ONLYUNRELATEDNAPTR: |
|
220
|
|
|
$out[] = _("This realm has NAPTR records, but none are related to this roaming consortium."); |
|
221
|
|
|
break; |
|
222
|
|
|
default: // if none of the possible negative retvals, then we have matching NAPTRs |
|
223
|
|
|
$out[] = sprintf(_("This realm has %d NAPTR records relating to this roaming consortium."), $this->naptr); |
|
224
|
|
|
} |
|
225
|
|
|
$out[] = "</td></tr>"; |
|
226
|
|
|
//print '<pre>'; print_r($out); print '</pre>'; exit; |
|
227
|
|
|
// compliance checks for NAPTRs |
|
228
|
|
|
if ($this->naptr > 0) { |
|
229
|
|
|
$out[] = "<tr><td>" . _("Checking NAPTR compliance (flag = S and regex = {empty}):") . "</td><td>"; |
|
230
|
|
|
switch ($this->naptrValid) { |
|
231
|
|
|
case \core\diag\RADIUSTests::RETVAL_OK: |
|
232
|
|
|
$out[] = "No issues found."; |
|
233
|
|
|
break; |
|
234
|
|
|
case \core\diag\RADIUSTests::RETVAL_INVALID: |
|
235
|
|
|
$out[] = _("At least one NAPTR with invalid content found!"); |
|
236
|
|
|
break; |
|
237
|
|
|
} |
|
238
|
|
|
$out[] = "</td></tr>"; |
|
239
|
|
|
} |
|
240
|
|
|
// SRV resolution |
|
241
|
|
|
if ($this->naptr > 0 && $this->naptrValid == \core\diag\RADIUSTests::RETVAL_OK) { |
|
242
|
|
|
$out[] = "<tr><td>" . _("Checking SRVs:") . "</td><td>"; |
|
243
|
|
|
switch ($this->srv) { |
|
244
|
|
|
case \core\diag\RADIUSTests::RETVAL_SKIPPED: |
|
245
|
|
|
$out[] = _("This check was skipped."); |
|
246
|
|
|
break; |
|
247
|
|
|
case \core\diag\RADIUSTests::RETVAL_INVALID: |
|
248
|
|
|
$out[] = _("At least one NAPTR with invalid content found!"); |
|
249
|
|
|
break; |
|
250
|
|
|
default: // print number of successfully retrieved SRV targets |
|
251
|
|
|
$out[] = sprintf(_("%d host names discovered."), $this->srv); |
|
252
|
|
|
} |
|
253
|
|
|
$out[] = "</td></tr>"; |
|
254
|
|
|
} |
|
255
|
|
|
// IP addresses for the hosts |
|
256
|
|
|
if ($this->naptr > 0 && $this->naptrValid == \core\diag\RADIUSTests::RETVAL_OK && $this->srv > 0) { |
|
257
|
|
|
$out[] = "<tr><td>" . _("Checking IP address resolution:") . "</td><td>"; |
|
258
|
|
|
switch ($this->srv) { |
|
259
|
|
|
case \core\diag\RADIUSTests::RETVAL_SKIPPED: |
|
260
|
|
|
$out[] = _("This check was skipped."); |
|
261
|
|
|
break; |
|
262
|
|
|
case \core\diag\RADIUSTests::RETVAL_INVALID: |
|
263
|
|
|
$out[] = _("At least one hostname could not be resolved!"); |
|
264
|
|
|
break; |
|
265
|
|
|
default: // print number of successfully retrieved SRV targets |
|
266
|
|
|
$out[] = sprintf(_("%d IP addresses resolved."), $this->hosts); |
|
267
|
|
|
} |
|
268
|
|
|
$out[] = "</td></tr>"; |
|
269
|
|
|
} |
|
270
|
|
|
|
|
271
|
|
|
$out[] = "</table><br/>"; |
|
272
|
|
|
$out[] = sprintf(_("Realm is <strong>%s</strong> "), _(($this->naptr > 0 ? "DYNAMIC" : "STATIC"))); |
|
273
|
|
|
if (count($this->testSuite->listerrors()) == 0) { |
|
274
|
|
|
$out[] = _("with no DNS errors encountered. Congratulations!"); |
|
275
|
|
|
} else { |
|
276
|
|
|
$out[] = _("but there were DNS errors! Check them!") . " " . _("You should re-run the tests after fixing the errors; more errors might be uncovered at that point. The exact error causes are listed below."); |
|
277
|
|
|
$out[] = "<div class='notacceptable'><table>"; |
|
278
|
|
|
foreach ($this->testSuite->listerrors() as $details) { |
|
279
|
|
|
$out[] = "<tr><td>" . $details['TYPE'] . "</td><td>" . $details['TARGET'] . "</td></tr>"; |
|
280
|
|
|
} |
|
281
|
|
|
$out[] = "</table></div>"; |
|
282
|
|
|
} |
|
283
|
|
|
$out[] = '</div>'; |
|
284
|
|
|
|
|
285
|
|
|
foreach ($this->rfc7585suite->NAPTR_hostname_records as $hostindex => $addr) { |
|
286
|
|
|
$host = ($addr['family'] == "IPv6" ? "[" : "") . $addr['IP'] . ($addr['family'] == "IPv6" ? "]" : "") . ":" . $addr['port']; |
|
|
|
|
|
|
287
|
|
|
$expectedName = $addr['hostname']; |
|
|
|
|
|
|
288
|
|
|
} |
|
289
|
|
|
} else { |
|
290
|
|
|
$out[] = "<tr><td>" . _("Dynamic discovery test is not configured") . "</td><td>"; |
|
291
|
|
|
} |
|
292
|
|
|
$out[] = "<hr><strong>" . _("Static connectivity tests") . "</strong> |
|
293
|
|
|
<table><tr> |
|
294
|
|
|
<td class='icon_td'>"; |
|
295
|
|
|
$out[] = "<img src='" . $this->stateIcons[$this->globalLevelStatic] . "' id='main_static_ico' class='icon'></td><td id='main_static_result'>" . |
|
296
|
|
|
$this->globalInfo[$this->globalLevelStatic] . ' ' . _("See the appropriate tab for details.") . '</td> |
|
297
|
|
|
</tr></table>'; |
|
298
|
|
|
if ($this->naptr > 0) { |
|
299
|
|
|
$out[] = "<hr><strong>" . _("Dynamic connectivity tests") . "</strong> |
|
300
|
|
|
<table><tr> |
|
301
|
|
|
<td class='icon_td'><img src='" . $this->stateIcons[$this->globalLevelDynamic] . "' id='main_dynamic_ico' class='icon'></td><td id='main_dynamic_result'>" . |
|
302
|
|
|
$this->globalInfo[$this->globalLevelDynamic] . ' ' . _("See the appropriate tab for details.") . '</td></tr></table>'; |
|
303
|
|
|
} |
|
304
|
|
|
$out[] = '</fieldset>'; |
|
305
|
|
|
//print '<pre>'; print_r($out); print '</pre>'; exit; |
|
306
|
|
|
return join('', $out); |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
public function printStatic() |
|
310
|
|
|
{ |
|
311
|
|
|
$out = []; |
|
312
|
|
|
$out[] = '<fieldset class="option_container" id="static_tests"> |
|
313
|
|
|
<legend><strong>'; |
|
314
|
|
|
$out[] = _("STATIC connectivity tests"); |
|
315
|
|
|
$out[] = '</strong> </legend>'; |
|
316
|
|
|
$out[] = _("This check sends a request for the realm through various entry points of the roaming consortium infrastructure. The request will contain the 'Operator-Name' attribute, and will be larger than 1500 Bytes to catch two common configuration problems.<br/>Since we don't have actual credentials for the realm, we can't authenticate successfully - so the expected outcome is to get an Access-Reject after having gone through an EAP conversation."); |
|
317
|
|
|
$out[] = '<p>'; |
|
318
|
|
|
foreach ($this->allReachabilityResults['udp'] as $udp) { |
|
319
|
|
|
$hostindex = $udp->hostindex; |
|
320
|
|
|
$result = $udp->result[0]; |
|
321
|
|
|
//print '<pre>'; print_r($result); print '</pre>'; |
|
322
|
|
|
$out[] = '<hr>'; |
|
323
|
|
|
$out[] = '<strong>' . sprintf(_("Testing from: %s"), \config\Diagnostics::RADIUSTESTS['UDP-hosts'][$hostindex]['display_name']) . '</strong>'; |
|
324
|
|
|
$out[] = "<table id='results$hostindex' style='width:100%' class='udp_results'> |
|
325
|
|
|
<tr> |
|
326
|
|
|
<td class='icon_td'><img src='" . $this->stateIcons[$result->level] . "' id='src" . $hostindex . "_img'></td> |
|
327
|
|
|
<td id='src$hostindex' colspan=2> |
|
328
|
|
|
"; |
|
329
|
|
|
$out[] = '<strong>' . ($result->server? $result->server : _("Connected to undetermined server")) . '</strong><br/>' . sprintf (_("elapsed time: %sms."), $result->time_millisec) . '<p>' . $result->message . '</p>'; |
|
330
|
|
|
|
|
331
|
|
|
if ($result->level > \core\common\Entity::L_OK && property_exists($result, 'cert_oddities')) { |
|
332
|
|
|
foreach ($result->cert_oddities as $oddities) { |
|
333
|
|
|
$out[] = '<tr class="results_tr"><td> </td><td class="icon_td"><img src="' . $icons[$oddities->level] . '"></td><td>' . $oddities->message . '</td></tr>'; |
|
|
|
|
|
|
334
|
|
|
} |
|
335
|
|
|
} |
|
336
|
|
|
$cert_data = ''; |
|
337
|
|
|
foreach ($result->server_cert as $sckey => $sc) { |
|
338
|
|
|
if (array_key_exists($sckey, $this->certFields)) { |
|
339
|
|
|
$cert_data .= '<dt>' . $this->certFields[$sckey] . '</dt><dd>' . $sc . '</dd>'; |
|
340
|
|
|
} |
|
341
|
|
|
} |
|
342
|
|
|
$out[] = "<tr class='server_cert' style='display: "; |
|
343
|
|
|
$out[] = ($result->server_cert? 'table-row' : 'none') . ";'><td> </td><td colspan=2><div><dl class='server_cert_list' style='display: none;'>"; |
|
344
|
|
|
$out[] = $cert_data; |
|
345
|
|
|
|
|
346
|
|
|
$ext = ''; |
|
347
|
|
|
foreach ($result->server_cert->extensions as $extkey => $extval) { |
|
348
|
|
|
if ($ext) { |
|
349
|
|
|
$ext .= '<br>'; |
|
350
|
|
|
} |
|
351
|
|
|
$ext .= '<strong>' . $extkey . ': </strong>' . '<i>' . $extval . '</i>'; |
|
352
|
|
|
} |
|
353
|
|
|
if ($ext != '') { |
|
354
|
|
|
$out[] = '<dt>' . _('Extensions') . '</dt></dd><dd>' . $ext . '</dd>'; |
|
355
|
|
|
} |
|
356
|
|
|
$out[] = "</dl><a href='' class='morelink'>" . _("show server certificate details") . "»</a></div></tr>"; |
|
357
|
|
|
|
|
358
|
|
|
$out[] = "</td></tr></table>"; |
|
359
|
|
|
} |
|
360
|
|
|
$out[] = '</fieldset>'; |
|
361
|
|
|
return join('', $out); |
|
362
|
|
|
} |
|
363
|
|
|
|
|
364
|
|
|
private function collectCAPath() |
|
365
|
|
|
{ |
|
366
|
|
|
$capathtest = []; |
|
367
|
|
|
$capathtest[] = '<p><strong>' . _("Checking server handshake...") . "</strong><p>"; |
|
368
|
|
|
foreach ($this->allReachabilityResults['capath'] as $capath) { |
|
369
|
|
|
//print '<pre>'; print_r($capath); print '<pre>'; |
|
370
|
|
|
$hostindex = $capath->hostindex; |
|
371
|
|
|
$level = $capath->level; |
|
372
|
|
|
if ($capath->level == \core\common\Entity::L_OK && $capath->result == \core\diag\RADIUSTests::RETVAL_INVALID) { |
|
373
|
|
|
$level = \core\common\Entity::L_WARN; |
|
374
|
|
|
} |
|
375
|
|
|
$capathtest[] = '<p><strong>' . $this->hostMap[$capath->IP] . '</strong>'; |
|
376
|
|
|
$capathtest[] = '<ul style="list-style-type: none;" class="caresult"><li>'; |
|
377
|
|
|
$capathtest[] = "<table id='caresults$hostindex' style='width:100%'> |
|
378
|
|
|
<tr> |
|
379
|
|
|
<td class='icon_td'><img src='"; |
|
380
|
|
|
$capathtest[] = $this->stateIcons[$level] . "' id='srcca" . $hostindex . "_img'></td> |
|
381
|
|
|
<td id='srcca$hostindex'>"; |
|
382
|
|
|
$more = ''; |
|
383
|
|
|
//print '<pre>'; print_r($server_cert); print '</pre>';print $server_cert['title'].'<br>'; |
|
384
|
|
|
if ($capath->certdata && $capath->certdata->subject != '') { |
|
385
|
|
|
$more .= '<div class="more">'; |
|
386
|
|
|
$certdesc = '<br>' . $this->certFields['title'] . '<ul>'; |
|
387
|
|
|
if ($capath->certdata->subject) { |
|
388
|
|
|
$certdesc .= '<li>' . $this->certFields['c_subject'] . ': ' . $capath->certdata->subject; |
|
389
|
|
|
} |
|
390
|
|
|
if ($capath->certdata->issuer) { |
|
391
|
|
|
$certdesc .= '<li>' . $this->certFields['c_issuer'] . ': ' . $capath->certdata->issuer; |
|
392
|
|
|
} |
|
393
|
|
|
if ($capath->certdata->extensions) { |
|
394
|
|
|
if ($capath->certdata->extensions->subjectaltname) { |
|
395
|
|
|
$certdesc .= '<li>' . $this->certFields['subjectaltname'] . ': ' . $capath->certdata->extensions->subjectaltname; |
|
396
|
|
|
} |
|
397
|
|
|
} |
|
398
|
|
|
if ($capath->certdata->extensions->policies) { |
|
399
|
|
|
$certdesc .= '<li>' . $this->certFields['policies'] . ': ' . $capath->certdata->extensions->policies; |
|
400
|
|
|
} |
|
401
|
|
|
if ($capath->certdata->extensions->crldistributionpoints) { |
|
402
|
|
|
$certdesc .= '<li>' . $this->certFields['crldistributionpoints'] . ': ' . $capath->certdata->extensions->crldistributionpoints; |
|
403
|
|
|
} |
|
404
|
|
|
if ($capath->certdata->extensions->authorityinfoaccess) { |
|
405
|
|
|
$certdesc .= '<li>' . $this->certFields['authorityinfoaccess'] . ': ' . $capath->certdata->extensions->authorityinfoaccess; |
|
406
|
|
|
} |
|
407
|
|
|
|
|
408
|
|
|
$certdesc .= '</ul>'; |
|
409
|
|
|
$more .= '<span class="morecontent"><span>' . $certdesc . |
|
410
|
|
|
'</span> <a href="" class="morelink">' . _("more") . '»</a></span></td></tr>'; |
|
411
|
|
|
} else { |
|
412
|
|
|
$certdesc = '<br>'; |
|
413
|
|
|
} |
|
414
|
|
|
$capathtest[] = '<div>' . ($capath->message!=''? $capath->message : _('Test failed')) . '</div>' . $more; |
|
415
|
|
|
$capathtest[] = '</td> |
|
416
|
|
|
</tr> |
|
417
|
|
|
</table>'; |
|
418
|
|
|
$capathtest[] = '</li></ul>'; |
|
419
|
|
|
} |
|
420
|
|
|
return $capathtest; |
|
421
|
|
|
} |
|
422
|
|
|
|
|
423
|
|
|
private function collectClients() |
|
424
|
|
|
{ |
|
425
|
|
|
$clientstest = []; |
|
426
|
|
|
foreach ($this->allReachabilityResults['clients'] as $clients) { |
|
427
|
|
|
//print '<pre>'; print_r($clients); print '</pre>'; |
|
428
|
|
|
$hostindex = $clients->hostindex; |
|
429
|
|
|
$clientstest[] = '<p><strong>' . $this->hostMap[$clients->IP] . '</strong></p>'; |
|
430
|
|
|
$clientstest[] = "<span id='clientresults$hostindex'>"; |
|
431
|
|
|
$clientstest[] = '<p></p>'; |
|
432
|
|
|
if ($this->globalLevelDynamic != \core\common\Entity::L_ERROR) { |
|
433
|
|
|
if (property_exists($clients, 'ca')) { |
|
434
|
|
|
$clientstest[] = '<ol>'; |
|
435
|
|
|
foreach ($clients->ca as $ca) { |
|
436
|
|
|
//print '<pre>'; print_r($ca); print '</pre>'; |
|
437
|
|
|
$srefused = 0; |
|
438
|
|
|
$cliinfo = ''; |
|
439
|
|
|
$cliinfo .= '<li>' . _('Client certificate') . ' <b>' . $ca->clientcertinfo->from . |
|
440
|
|
|
'</b>' . ', ' . $ca->clientcertinfo->message . |
|
441
|
|
|
'<br> (CA: ' . $ca->clientcertinfo->issuer . ')<ul>'; |
|
442
|
|
|
foreach ($ca->certificate as $certificate) { |
|
443
|
|
|
if ($certificate->returncode == \core\diag\RADIUSTests::RETVAL_CONNECTION_REFUSED) { |
|
444
|
|
|
$srefused = 1; |
|
445
|
|
|
} |
|
446
|
|
|
} |
|
447
|
|
|
if ($srefused == 0) { |
|
448
|
|
|
foreach ($ca->certificate as $certificate) { |
|
449
|
|
|
$cliinfo .= '<li><i>' . $certificate->message . |
|
450
|
|
|
', ' . _("expected result: ") . $this->states[$certificate->expected] . '</i>'; |
|
451
|
|
|
$cliinfo .= '<ul style="list-style-type: none;">'; |
|
452
|
|
|
$level = $certificate->returncode; |
|
453
|
|
|
if ($level < 0) { |
|
454
|
|
|
$level = \core\common\Entity::L_ERROR; |
|
455
|
|
|
} |
|
456
|
|
|
$add = ''; |
|
457
|
|
|
if ($certificate->expected == 'PASS') { |
|
458
|
|
|
if ($certificate->connected == 1) { |
|
459
|
|
|
$state = _("Server accepted this client certificate"); |
|
460
|
|
|
} else { |
|
461
|
|
|
if (property_exists($certificate, 'reason') && $certificate->reason == \core\diag\RADIUSTests::CERTPROB_UNKNOWN_CA) { |
|
462
|
|
|
$add = '<br>' . _('You should update your list of accredited CAs') . |
|
463
|
|
|
' <a href=\"' . \config\Diagnostics::RADIUSTESTS['accreditedCAsURL'] . '\">' . |
|
464
|
|
|
_('Get it from here.') . '</a>'; |
|
465
|
|
|
} |
|
466
|
|
|
$state = _('Server did not accept this client certificate - reason') . ': ' . |
|
467
|
|
|
$certificate->resultcomment; |
|
468
|
|
|
} |
|
469
|
|
|
} else { |
|
470
|
|
|
if ($certificate->connected == 1) { |
|
471
|
|
|
$level = \core\common\Entity::L_WARN; |
|
472
|
|
|
$state = _('Server accepted this client certificate, but should not have'); |
|
473
|
|
|
} else { |
|
474
|
|
|
$level = \core\common\Entity::L_OK; |
|
475
|
|
|
$state = _('Server did not accept this client certificate') . ': ' . $certificate->resultcomment; |
|
476
|
|
|
} |
|
477
|
|
|
} |
|
478
|
|
|
$cliinfo .= '<li><table><tbody><tr><td class="icon_td"><img class="icon" src="' . $this->stateIcons[$level] . '" style="width: 24px;"></td><td>' . $state; |
|
479
|
|
|
$cliinfo .= ' (' . sprintf(_('elapsed time: %sms.'), $certificate->time_millisec) . ' ) ' . $add . '</td></tr>'; |
|
480
|
|
|
$cliinfo .= '</tbody></table></ul></li>'; |
|
481
|
|
|
if (property_exists($certificate, 'finalerror') && $certificate->finalerror == 1) { |
|
482
|
|
|
$cliinfo = '<li>' . _('Rest of tests for this CA skipped') . '</li>'; |
|
483
|
|
|
} |
|
484
|
|
|
} |
|
485
|
|
|
$clients_level = max($clients_level, $level); |
|
|
|
|
|
|
486
|
|
|
$cliinfo .= '</ul>'; |
|
487
|
|
|
} |
|
488
|
|
|
|
|
489
|
|
|
if ($srefused > 0) { |
|
490
|
|
|
$cliinfo = _('Connection refused'); |
|
491
|
|
|
$clientstest[] = "<table><tr><td class='icon_td' id='srcclient$hostindex_img'><img src='" . $this->stateIcons[\core\common\Entity::L_ERROR] . "'></td>" . |
|
|
|
|
|
|
492
|
|
|
"<td id='srcclient$hostname'><p>$cliinfo</p></td></tr></table>"; |
|
|
|
|
|
|
493
|
|
|
} else { |
|
494
|
|
|
$clientstest[] = "<p>$cliinfo</p>"; |
|
495
|
|
|
} |
|
496
|
|
|
} |
|
497
|
|
|
$cliinfo .= '</ol>'; |
|
|
|
|
|
|
498
|
|
|
} else { |
|
499
|
|
|
$clients_level = \core\common\Entity::L_WARN; |
|
500
|
|
|
$cliinfo = _('Test failed') ; |
|
501
|
|
|
$clientstest[] = "<table><tr><td class='icon_td' id='srcclient$hostindex_img'><img src='" . |
|
502
|
|
|
$this->stateIcons[\core\common\Entity::L_WARN] . "'></td>" . |
|
503
|
|
|
"<td id='srcclient$hostname'>$cliinfo</td></tr></table>"; |
|
504
|
|
|
} |
|
505
|
|
|
} else { |
|
506
|
|
|
$clientstest[] = '<ul style="list-style-type: none;" class="clientsresult"><li>'; |
|
507
|
|
|
$clientstest[] = "<table id='clientsresults$hostindex' style='width:100%'> |
|
508
|
|
|
<tr> |
|
509
|
|
|
<td class='icon_td'><img src='"; |
|
510
|
|
|
$clientstest[] = $this->stateIcons[\core\common\Entity::L_ERROR] . "' id='srcclients" . $hostindex . "_img'></td> |
|
511
|
|
|
<td id='srcclient$hostindex'>"; |
|
512
|
|
|
$clientstest[] = _("These tests were skipped because of previous errors.") . '</td></tr></table></ul>'; |
|
513
|
|
|
} |
|
514
|
|
|
$clientstest[] = '</ol><p></p>'; |
|
515
|
|
|
} |
|
516
|
|
|
return $clientstest; |
|
517
|
|
|
} |
|
518
|
|
|
|
|
519
|
|
|
public function printDynamic() |
|
520
|
|
|
{ |
|
521
|
|
|
$out = []; |
|
522
|
|
|
$out[] = "<div id='dynamic_tests'><fieldset class='option_container'> |
|
523
|
|
|
<legend><strong>" . _("DYNAMIC connectivity tests") . "</strong></legend>"; |
|
524
|
|
|
|
|
525
|
|
|
if (count($this->rfc7585suite->NAPTR_hostname_records) > 0) { |
|
526
|
|
|
$capathtest = $this->collectCAPath(); |
|
527
|
|
|
$clientstest = $this->collectClients(); |
|
528
|
|
|
//print '<pre>'; print_r($clientstest); print '</pre>'; |
|
529
|
|
|
$out[] = '<div style="align:right;">'; |
|
530
|
|
|
$out[] = '<div style="align:right; display: '; |
|
531
|
|
|
if ($this->globalLevelDynamic == \core\common\Entity::L_OK && !$this->areFailed) { |
|
532
|
|
|
$out[] = 'none'; |
|
533
|
|
|
} |
|
534
|
|
|
$out[] = ';" id="dynamic_result_fail"><b>' . _("Some errors were found during the tests, see below") . '</b></div>'; |
|
535
|
|
|
$out[] = '<div style="align:right; display: '; |
|
536
|
|
|
if ($this->globalLevelDynamic != \core\common\Entity::L_OK || $this->areFailed) { |
|
537
|
|
|
$out[] = 'none'; |
|
538
|
|
|
} |
|
539
|
|
|
$out[] = '" id="dynamic_result_pass"><b>' . |
|
540
|
|
|
_("All tests passed, congratulations!") . '</b></div>' . |
|
541
|
|
|
'<div style="align:left;"><a href="" class="moreall"><i>' . _('Show detailed information for all tests') . '»</i></a></div>'; |
|
542
|
|
|
//print '<pre>'; print_r($clientstest); print '</pre>'; |
|
543
|
|
|
$out[] = join('', $capathtest); |
|
544
|
|
|
$out[] = '<span id="clientstest" style="display: ;"><p><hr><b>' . _('Checking if certificates from CAs are accepted...') . '</b><p>' . _('A few client certificates will be tested to check if servers are resistant to some certificate problems.') . '<p>'; |
|
545
|
|
|
$out[] = join('', $clientstest); |
|
546
|
|
|
$out[] = '</span>'; |
|
547
|
|
|
$out[] = '</div>'; |
|
548
|
|
|
} |
|
549
|
|
|
$out[] = "</fieldset></div></div>"; |
|
550
|
|
|
return join('', $out); |
|
551
|
|
|
} |
|
552
|
|
|
|
|
553
|
|
|
} |
|
554
|
|
|
|