Projet

Général

Profil

Télécharger (43,8 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_certmanager.php @ 7e736f38

1
<?php
2
/*
3
    system_certmanager.php
4

    
5
    Copyright (C) 2008 Shrew Soft Inc.
6
    All rights reserved.
7

    
8
    Redistribution and use in source and binary forms, with or without
9
    modification, are permitted provided that the following conditions are met:
10

    
11
    1. Redistributions of source code must retain the above copyright notice,
12
       this list of conditions and the following disclaimer.
13

    
14
    2. Redistributions in binary form must reproduce the above copyright
15
       notice, this list of conditions and the following disclaimer in the
16
       documentation and/or other materials provided with the distribution.
17

    
18
    THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
19
    INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
20
    AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
21
    AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
22
    OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23
    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24
    INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25
    CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26
    ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27
    POSSIBILITY OF SUCH DAMAGE.
28
*/
29
/*
30
	pfSense_MODULE:	certificate_managaer
31
*/
32

    
33
##|+PRIV
34
##|*IDENT=page-system-certmanager
35
##|*NAME=System: Certificate Manager
36
##|*DESCR=Allow access to the 'System: Certificate Manager' page.
37
##|*MATCH=system_certmanager.php*
38
##|-PRIV
39

    
40
require("guiconfig.inc");
41
require_once("certs.inc");
42

    
43
$cert_methods = array(
44
	"import" => gettext("Import an existing Certificate"),
45
	"internal" => gettext("Create an internal Certificate"),
46
	"external" => gettext("Create a Certificate Signing Request"),
47
);
48

    
49
$cert_keylens = array( "512", "1024", "2048", "4096");
50
$cert_types = array(	"ca" => "Certificate Authority",
51
			"server" => "Server Certificate",
52
			"user" => "User Certificate");
53

    
54
$altname_types = array("DNS", "IP", "email", "URI");
55
$openssl_digest_algs = array("sha1", "sha224", "sha256", "sha384", "sha512");
56

    
57
$pgtitle = array(gettext("System"), gettext("Certificate Manager"));
58

    
59
if (is_numericint($_GET['userid']))
60
	$userid = $_GET['userid'];
61
if (isset($_POST['userid']) && is_numericint($_POST['userid']))
62
	$userid = $_POST['userid'];
63

    
64
if (isset($userid)) {
65
	$cert_methods["existing"] = gettext("Choose an existing certificate");
66
	if (!is_array($config['system']['user']))
67
		$config['system']['user'] = array();
68
	$a_user =& $config['system']['user'];
69
}
70

    
71
if (is_numericint($_GET['id']))
72
	$id = $_GET['id'];
73
if (isset($_POST['id']) && is_numericint($_POST['id']))
74
	$id = $_POST['id'];
75

    
76
if (!is_array($config['ca']))
77
	$config['ca'] = array();
78

    
79
$a_ca =& $config['ca'];
80

    
81
if (!is_array($config['cert']))
82
	$config['cert'] = array();
83

    
84
$a_cert =& $config['cert'];
85

    
86
$internal_ca_count = 0;
87
foreach ($a_ca as $ca)
88
	if ($ca['prv'])	
89
		$internal_ca_count++;
90

    
91
$act = $_GET['act'];
92
if ($_POST['act'])
93
	$act = $_POST['act'];
94

    
95
if ($act == "del") {
96

    
97
	if (!isset($a_cert[$id])) {
98
		pfSenseHeader("system_certmanager.php");
99
		exit;
100
	}
101

    
102
	$name = $a_cert[$id]['descr'];
103
	unset($a_cert[$id]);
104
	write_config();
105
	$savemsg = sprintf(gettext("Certificate %s successfully deleted"), $name) . "<br/>";
106
	pfSenseHeader("system_certmanager.php");
107
	exit;
108
}
109

    
110
if ($act == "new") {
111
	$pconfig['method'] = $_GET['method'];
112
	$pconfig['keylen'] = "2048";
113
	$pconfig['digest_alg'] = "sha256";
114
	$pconfig['csr_keylen'] = "2048";
115
	$pconfig['csr_digest_alg'] = "sha256";
116
	$pconfig['type'] = "user";
117
	$pconfig['lifetime'] = "3650";
118
}
119

    
120
if ($act == "exp") {
121

    
122
	if (!$a_cert[$id]) {
123
		pfSenseHeader("system_certmanager.php");
124
		exit;
125
	}
126

    
127
	$exp_name = urlencode("{$a_cert[$id]['descr']}.crt");
128
	$exp_data = base64_decode($a_cert[$id]['crt']);
129
	$exp_size = strlen($exp_data);
130

    
131
	header("Content-Type: application/octet-stream");
132
	header("Content-Disposition: attachment; filename={$exp_name}");
133
	header("Content-Length: $exp_size");
134
	echo $exp_data;
135
	exit;
136
}
137

    
138
if ($act == "key") {
139

    
140
	if (!$a_cert[$id]) {
141
		pfSenseHeader("system_certmanager.php");
142
		exit;
143
	}
144

    
145
	$exp_name = urlencode("{$a_cert[$id]['descr']}.key");
146
	$exp_data = base64_decode($a_cert[$id]['prv']);
147
	$exp_size = strlen($exp_data);
148

    
149
	header("Content-Type: application/octet-stream");
150
	header("Content-Disposition: attachment; filename={$exp_name}");
151
	header("Content-Length: $exp_size");
152
	echo $exp_data;
153
	exit;
154
}
155

    
156
if ($act == "p12") {
157
	if (!$a_cert[$id]) {
158
		pfSenseHeader("system_certmanager.php");
159
		exit;
160
	}
161

    
162
	$exp_name = urlencode("{$a_cert[$id]['descr']}.p12");
163

    
164
	$res_crt = openssl_x509_read(base64_decode($a_cert[$id]['crt']));
165
	$res_key = openssl_pkey_get_private(array(0 => base64_decode($a_cert[$id]['prv']) , 1 => ""));
166

    
167
	$exp_data = "";
168
	openssl_pkcs12_export($res_crt, $exp_data, $res_key, null);
169
	$exp_size = strlen($exp_data);
170

    
171
	header("Content-Type: application/octet-stream");
172
	header("Content-Disposition: attachment; filename={$exp_name}");
173
	header("Content-Length: $exp_size");
174
	echo $exp_data;
175
	exit;
176
}
177

    
178
if ($act == "csr") {
179

    
180
	if (!$a_cert[$id]) {
181
		pfSenseHeader("system_certmanager.php");
182
		exit;
183
	}
184

    
185
	$pconfig['descr'] = $a_cert[$id]['descr'];
186
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
187
}
188

    
189
if ($_POST) {
190
	if ($_POST['save'] == gettext("Save")) {
191
		$input_errors = array();
192
		$pconfig = $_POST;
193

    
194
		/* input validation */
195
		if ($pconfig['method'] == "import") {
196
			$reqdfields = explode(" ",
197
					"descr cert key");
198
			$reqdfieldsn = array(
199
					gettext("Descriptive name"),
200
					gettext("Certificate data"),
201
					gettext("Key data"));
202
			if ($_POST['cert'] && (!strstr($_POST['cert'], "BEGIN CERTIFICATE") || !strstr($_POST['cert'], "END CERTIFICATE")))
203
				$input_errors[] = gettext("This certificate does not appear to be valid.");
204
		}
205

    
206
		if ($pconfig['method'] == "internal") {
207
			$reqdfields = explode(" ",
208
					"descr caref keylen type lifetime dn_country dn_state dn_city ".
209
					"dn_organization dn_email dn_commonname");
210
			$reqdfieldsn = array(
211
					gettext("Descriptive name"),
212
					gettext("Certificate authority"),
213
					gettext("Key length"),
214
					gettext("Certificate Type"),
215
					gettext("Lifetime"),
216
					gettext("Distinguished name Country Code"),
217
					gettext("Distinguished name State or Province"),
218
					gettext("Distinguished name City"),
219
					gettext("Distinguished name Organization"),
220
					gettext("Distinguished name Email Address"),
221
					gettext("Distinguished name Common Name"));
222
		}
223

    
224
		if ($pconfig['method'] == "external") {
225
			$reqdfields = explode(" ",
226
					"descr csr_keylen csr_dn_country csr_dn_state csr_dn_city ".
227
					"csr_dn_organization csr_dn_email csr_dn_commonname");
228
			$reqdfieldsn = array(
229
					gettext("Descriptive name"),
230
					gettext("Key length"),
231
					gettext("Distinguished name Country Code"),
232
					gettext("Distinguished name State or Province"),
233
					gettext("Distinguished name City"),
234
					gettext("Distinguished name Organization"),
235
					gettext("Distinguished name Email Address"),
236
					gettext("Distinguished name Common Name"));
237
		}
238

    
239
		if ($pconfig['method'] == "existing") {
240
			$reqdfields = array("certref");
241
			$reqdfieldsn = array(gettext("Existing Certificate Choice"));
242
		}
243

    
244
		$altnames = array();
245
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
246
		if ($pconfig['method'] != "import" && $pconfig['method'] != "existing") {
247
			/* subjectAltNames */
248
			foreach ($_POST as $key => $value) {
249
				$entry = '';
250
				if (!substr_compare('altname_type', $key, 0, 12)) {
251
					$entry = substr($key, 12);
252
					$field = 'type';
253
				}
254
				elseif (!substr_compare('altname_value', $key, 0, 13)) {
255
					$entry = substr($key, 13);
256
					$field = 'value';
257
				}
258
				if (ctype_digit($entry)) {
259
					$altnames[$entry][$field] = $value;
260
				}
261
			}
262
			$pconfig['altnames']['item'] = $altnames;
263

    
264
			/* Input validation for subjectAltNames */
265
			foreach ($altnames as $idx => $altname) {
266
				switch ($altname['type']) {
267
					case "DNS":
268
						if (!is_hostname($altname['value']))
269
							array_push($input_errors, "DNS subjectAltName values must be valid hostnames or FQDNs");
270
						break;
271
					case "IP":
272
						if (!is_ipaddr($altname['value']))
273
							array_push($input_errors, "IP subjectAltName values must be valid IP Addresses");
274
						break;
275
					case "email":
276
						if (empty($altname['value']))
277
							array_push($input_errors, "You must provide an e-mail address for this type of subjectAltName");
278
						if (preg_match("/[\!\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $altname['value']))
279
							array_push($input_errors, "The e-mail provided in a subjectAltName contains invalid characters.");
280
						break;
281
					case "URI":
282
						/* Close enough? */
283
						if (!is_URL($altname['value']))
284
							$input_errors[] = "URI subjectAltName types must be a valid URI";
285
						break;
286
					default:
287
						$input_errors[] = "Unrecognized subjectAltName type.";
288
				}
289
			}
290

    
291
			/* Make sure we do not have invalid characters in the fields for the certificate */
292
			for ($i = 0; $i < count($reqdfields); $i++) {
293
				if (preg_match('/email/', $reqdfields[$i])){ /* dn_email or csr_dn_name */
294
					if (preg_match("/[\!\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST[$reqdfields[$i]]))
295
						array_push($input_errors, "The field 'Distinguished name Email Address' contains invalid characters.");
296
				}else if (preg_match('/commonname/', $reqdfields[$i])){ /* dn_commonname or csr_dn_commonname */
297
					if (preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST[$reqdfields[$i]]))
298
						array_push($input_errors, "The field 'Distinguished name Common Name' contains invalid characters.");
299
				}else if (($reqdfields[$i] != "descr") && preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\.\"\']/", $_POST[$reqdfields[$i]]))
300
					array_push($input_errors, "The field '" . $reqdfieldsn[$i] . "' contains invalid characters.");
301
			}
302

    
303
			if (($pconfig['method'] != "external") && isset($_POST["keylen"]) && !in_array($_POST["keylen"], $cert_keylens))
304
				array_push($input_errors, gettext("Please select a valid Key Length."));
305
			if (($pconfig['method'] != "external") && !in_array($_POST["digest_alg"], $openssl_digest_algs))
306
				array_push($input_errors, gettext("Please select a valid Digest Algorithm."));
307
				
308
			if (($pconfig['method'] == "external") && isset($_POST["csr_keylen"]) && !in_array($_POST["csr_keylen"], $cert_keylens))
309
				array_push($input_errors, gettext("Please select a valid Key Length."));
310
			if (($pconfig['method'] == "external") && !in_array($_POST["csr_digest_alg"], $openssl_digest_algs))
311
				array_push($input_errors, gettext("Please select a valid Digest Algorithm."));
312
		}
313

    
314
		/* if this is an AJAX caller then handle via JSON */
315
		if (isAjax() && is_array($input_errors)) {
316
			input_errors2Ajax($input_errors);
317
			exit;
318
		}
319

    
320
		/* save modifications */
321
		if (!$input_errors) {
322

    
323
			if ($pconfig['method'] == "existing") {
324
				$cert = lookup_cert($pconfig['certref']);
325
				if ($cert && $a_user)
326
					$a_user[$userid]['cert'][] = $cert['refid'];
327
			} else {
328
				$cert = array();
329
				$cert['refid'] = uniqid();
330
				if (isset($id) && $a_cert[$id])
331
					$cert = $a_cert[$id];
332

    
333
				$cert['descr'] = $pconfig['descr'];
334

    
335
				$old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warings directly to a page screwing menu tab */
336

    
337
				if ($pconfig['method'] == "import")
338
					cert_import($cert, $pconfig['cert'], $pconfig['key']);
339

    
340
				if ($pconfig['method'] == "internal") {
341
					$dn = array(
342
						'countryName' => $pconfig['dn_country'],
343
						'stateOrProvinceName' => $pconfig['dn_state'],
344
						'localityName' => $pconfig['dn_city'],
345
						'organizationName' => $pconfig['dn_organization'],
346
						'emailAddress' => $pconfig['dn_email'],
347
						'commonName' => $pconfig['dn_commonname']);
348
					if (count($altnames)) {
349
						$altnames_tmp = "";
350
						foreach ($altnames as $altname) {
351
							$altnames_tmp[] = "{$altname['type']}:{$altname['value']}";
352
						}
353
						$dn['subjectAltName'] = implode(",", $altnames_tmp);
354
					}
355
					if (!cert_create($cert, $pconfig['caref'], $pconfig['keylen'],
356
						$pconfig['lifetime'], $dn, $pconfig['type'], $pconfig['digest_alg'])){
357
						while($ssl_err = openssl_error_string()){
358
							$input_errors = array();
359
							array_push($input_errors, "openssl library returns: " . $ssl_err);
360
						}
361
					}
362
				}
363

    
364
				if ($pconfig['method'] == "external") {
365
					$dn = array(
366
						'countryName' => $pconfig['csr_dn_country'],
367
						'stateOrProvinceName' => $pconfig['csr_dn_state'],
368
						'localityName' => $pconfig['csr_dn_city'],
369
						'organizationName' => $pconfig['csr_dn_organization'],
370
						'emailAddress' => $pconfig['csr_dn_email'],
371
						'commonName' => $pconfig['csr_dn_commonname']);
372
					if (count($altnames)) {
373
						$altnames_tmp = "";
374
						foreach ($altnames as $altname) {
375
							$altnames_tmp[] = "{$altname['type']}:{$altname['value']}";
376
						}
377
						$dn['subjectAltName'] = implode(",", $altnames_tmp);
378
					}
379
					if(!csr_generate($cert, $pconfig['csr_keylen'], $dn, $pconfig['csr_digest_alg'])){
380
						while($ssl_err = openssl_error_string()){
381
							$input_errors = array();
382
							array_push($input_errors, "openssl library returns: " . $ssl_err);
383
						}
384
					}
385
				}
386
				error_reporting($old_err_level);
387

    
388
				if (isset($id) && $a_cert[$id])
389
					$a_cert[$id] = $cert;
390
				else
391
					$a_cert[] = $cert;
392
				if (isset($a_user) && isset($userid))
393
					$a_user[$userid]['cert'][] = $cert['refid'];
394
			}
395

    
396
			if (!$input_errors)
397
				write_config();
398

    
399
			if ($userid)
400
				pfSenseHeader("system_usermanager.php?act=edit&id={$userid}");
401
		}
402
	}
403

    
404
	if ($_POST['save'] == gettext("Update")) {
405
		unset($input_errors);
406
		$pconfig = $_POST;
407

    
408
		/* input validation */
409
		$reqdfields = explode(" ", "descr cert");
410
		$reqdfieldsn = array(
411
			gettext("Descriptive name"),
412
			gettext("Final Certificate data"));
413

    
414
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
415

    
416
//		old way
417
		/* make sure this csr and certificate subjects match */
418
//		$subj_csr = csr_get_subject($pconfig['csr'], false);
419
//		$subj_cert = cert_get_subject($pconfig['cert'], false);
420
//
421
//		if ( !isset($_POST['ignoresubjectmismatch']) && !($_POST['ignoresubjectmismatch'] == "yes") ) {
422
//			if (strcmp($subj_csr,$subj_cert)) {
423
//				$input_errors[] = sprintf(gettext("The certificate subject '%s' does not match the signing request subject."),$subj_cert);
424
//				$subject_mismatch = true;
425
//			}
426
//		}
427
		$mod_csr  =  csr_get_modulus($pconfig['csr'], false);
428
		$mod_cert = cert_get_modulus($pconfig['cert'], false);
429
		
430
		if (strcmp($mod_csr,$mod_cert)) {
431
			// simply: if the moduli don't match, then the private key and public key won't match
432
			$input_errors[] = sprintf(gettext("The certificate modulus does not match the signing request modulus."),$subj_cert);
433
			$subject_mismatch = true;
434
		}
435

    
436
		/* if this is an AJAX caller then handle via JSON */
437
		if (isAjax() && is_array($input_errors)) {
438
			input_errors2Ajax($input_errors);
439
			exit;
440
		}
441

    
442
		/* save modifications */
443
		if (!$input_errors) {
444

    
445
			$cert = $a_cert[$id];
446

    
447
			$cert['descr'] = $pconfig['descr'];
448

    
449
			csr_complete($cert, $pconfig['cert']);
450

    
451
			$a_cert[$id] = $cert;
452

    
453
			write_config();
454

    
455
			pfSenseHeader("system_certmanager.php");
456
		}
457
	}
458
}
459

    
460
include("head.inc");
461
?>
462

    
463
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
464
<?php include("fbegin.inc"); ?>
465
<script type="text/javascript">
466
//<![CDATA[
467

    
468
function method_change() {
469

    
470
<?php
471
	if ($internal_ca_count)
472
		$submit_style = "";
473
	else
474
		$submit_style = "none";
475
?>
476

    
477
	method = document.iform.method.selectedIndex;
478

    
479
	switch (method) {
480
		case 0:
481
			document.getElementById("import").style.display="";
482
			document.getElementById("internal").style.display="none";
483
			document.getElementById("external").style.display="none";
484
			document.getElementById("existing").style.display="none";
485
			document.getElementById("descriptivename").style.display="";
486
			document.getElementById("submit").style.display="";
487
			break;
488
		case 1:
489
			document.getElementById("import").style.display="none";
490
			document.getElementById("internal").style.display="";
491
			document.getElementById("external").style.display="none";
492
			document.getElementById("existing").style.display="none";
493
			document.getElementById("descriptivename").style.display="";
494
			document.getElementById("submit").style.display="<?=$submit_style;?>";
495
			break;
496
		case 2:
497
			document.getElementById("import").style.display="none";
498
			document.getElementById("internal").style.display="none";
499
			document.getElementById("external").style.display="";
500
			document.getElementById("existing").style.display="none";
501
			document.getElementById("descriptivename").style.display="";
502
			document.getElementById("submit").style.display="";
503
			break;
504
		case 3:
505
			document.getElementById("import").style.display="none";
506
			document.getElementById("internal").style.display="none";
507
			document.getElementById("external").style.display="none";
508
			document.getElementById("existing").style.display="";
509
			document.getElementById("descriptivename").style.display="none";
510
			document.getElementById("submit").style.display="";
511
			break;
512
	}
513
}
514

    
515
<?php if ($internal_ca_count): ?>
516
function internalca_change() {
517

    
518
	index = document.iform.caref.selectedIndex;
519
	caref = document.iform.caref[index].value;
520

    
521
	switch (caref) {
522
<?php
523
		foreach ($a_ca as $ca):
524
			if (!$ca['prv'])
525
				continue;
526
			$subject = cert_get_subject_array($ca['crt']);
527
?>
528
		case "<?=$ca['refid'];?>":
529
			document.iform.dn_country.value = "<?=$subject[0]['v'];?>";
530
			document.iform.dn_state.value = "<?=$subject[1]['v'];?>";
531
			document.iform.dn_city.value = "<?=$subject[2]['v'];?>";
532
			document.iform.dn_organization.value = "<?=$subject[3]['v'];?>";
533
			document.iform.dn_email.value = "<?=$subject[4]['v'];?>";
534
			break;
535
<?php	endforeach; ?>
536
	}
537
}
538
<?php endif; ?>
539

    
540
//]]>
541
</script>
542
<script type="text/javascript" src="/javascript/row_helper_dynamic.js"></script>
543
<input type='hidden' name='altname_value_type' value='select' />
544
<input type='hidden' name='altname_type_type' value='textbox' />
545
<script type="text/javascript">
546
//<![CDATA[
547
	rowname[0] = "altname_type";
548
	rowtype[0] = "textbox";
549
	rowsize[0] = "10";
550
	rowname[1] = "altname_value";
551
	rowtype[1] = "textbox";
552
	rowsize[1] = "30";
553
//]]>
554
</script>
555
<?php
556
	if ($input_errors)
557
		print_input_errors($input_errors);
558
	if ($savemsg)
559
		print_info_box($savemsg);
560

    
561
        // Load valid country codes
562
        $dn_cc = array();
563
        if (file_exists("/etc/ca_countries")){
564
                $dn_cc_file=file("/etc/ca_countries");
565
                foreach($dn_cc_file as $line)
566
                        if (preg_match('/^(\S*)\s(.*)$/', $line, $matches))
567
                                array_push($dn_cc, $matches[1]);
568
        }
569
?>
570
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="cert manager">
571
	<tr>
572
		<td class="tabnavtbl">
573
		<?php
574
			$tab_array = array();
575
			$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
576
			$tab_array[] = array(gettext("Certificates"), true, "system_certmanager.php");
577
			$tab_array[] = array(gettext("Certificate Revocation"), false, "system_crlmanager.php");
578
			display_top_tabs($tab_array);
579
		?>
580
		</td>
581
	</tr>
582
	<tr>
583
		<td id="mainarea">
584
			<div class="tabcont">
585

    
586
				<?php if ($act == "new" || (($_POST['save'] == gettext("Save")) && $input_errors)): ?>
587

    
588
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
589
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area">
590
						<?php if (!isset($id)): ?>
591
						<tr>
592
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
593
							<td width="78%" class="vtable">
594
								<select name='method' id='method' class="formselect" onchange='method_change()'>
595
								<?php
596
									foreach($cert_methods as $method => $desc):
597
									$selected = "";
598
									if ($pconfig['method'] == $method)
599
										$selected = " selected=\"selected\"";
600
								?>
601
									<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option>
602
								<?php endforeach; ?>
603
								</select>
604
							</td>
605
						</tr>
606
						<?php endif; ?>
607
						<tr id="descriptivename">
608
							<?php
609
							if ($a_user && empty($pconfig['descr']))
610
								$pconfig['descr'] = $a_user[$userid]['name'];
611
							?>
612
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
613
							<td width="78%" class="vtable">
614
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
615
							</td>
616
						</tr>
617
					</table>
618

    
619
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="import" summary="import">
620
						<tr>
621
							<td colspan="2" class="list" height="12"></td>
622
						</tr>
623
						<tr>
624
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Import Certificate");?></td>
625
						</tr>
626

    
627
						<tr>
628
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td>
629
							<td width="78%" class="vtable">
630
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea>
631
								<br/>
632
								<?=gettext("Paste a certificate in X.509 PEM format here.");?>
633
							</td>
634
						</tr>
635
						<tr>
636
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Private key data");?></td>
637
							<td width="78%" class="vtable">
638
								<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['key']);?></textarea>
639
								<br/>
640
								<?=gettext("Paste a private key in X.509 PEM format here.");?>
641
							</td>
642
						</tr>
643
					</table>
644

    
645
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal" summary="internal">
646
						<tr>
647
							<td colspan="2" class="list" height="12"></td>
648
						</tr>
649
						<tr>
650
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate");?></td>
651
						</tr>
652

    
653
						<?php if (!$internal_ca_count): ?>
654

    
655
						<tr>
656
							<td colspan="2" align="center" class="vtable">
657
								<?=gettext("No internal Certificate Authorities have been defined. You must");?>
658
								<a href="system_camanager.php?act=new&amp;method=internal"><?=gettext("create");?></a>
659
								<?=gettext("an internal CA before creating an internal certificate.");?>
660
							</td>
661
						</tr>
662

    
663
						<?php else: ?>
664

    
665
						<tr>
666
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
667
							<td width="78%" class="vtable">
668
								<select name='caref' id='caref' class="formselect" onchange='internalca_change()'>
669
								<?php
670
									foreach( $a_ca as $ca):
671
									if (!$ca['prv'])
672
										continue;
673
									$selected = "";
674
									if ($pconfig['caref'] == $ca['refid'])
675
										$selected = " selected=\"selected\"";
676
								?>
677
									<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['descr'];?></option>
678
								<?php endforeach; ?>
679
								</select>
680
							</td>
681
						</tr>
682
						<tr>
683
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
684
							<td width="78%" class="vtable">
685
								<select name='keylen' class="formselect">
686
								<?php
687
									foreach( $cert_keylens as $len):
688
									$selected = "";
689
									if ($pconfig['keylen'] == $len)
690
										$selected = " selected=\"selected\"";
691
								?>
692
									<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
693
								<?php endforeach; ?>
694
								</select>
695
								<?=gettext("bits");?>
696
							</td>
697
						</tr>
698
						<tr>
699
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Digest Algorithm");?></td>
700
							<td width="78%" class="vtable">
701
								<select name='digest_alg' id='digest_alg' class="formselect">
702
								<?php
703
									foreach( $openssl_digest_algs as $digest_alg):
704
									$selected = "";
705
									if ($pconfig['digest_alg'] == $digest_alg)
706
										$selected = " selected=\"selected\"";
707
								?>
708
									<option value="<?=$digest_alg;?>"<?=$selected;?>><?=strtoupper($digest_alg);?></option>
709
								<?php endforeach; ?>
710
								</select>
711
								<br/><?= gettext("NOTE: It is recommended to use an algorithm stronger than SHA1 when possible.") ?>
712
							</td>
713
						</tr>
714
						<tr>
715
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate Type");?></td>
716
							<td width="78%" class="vtable">
717
								<select name='type' class="formselect">
718
								<?php
719
									foreach( $cert_types as $ct => $ctdesc ):
720
									$selected = "";
721
									if ($pconfig['type'] == $ct)
722
										$selected = " selected=\"selected\"";
723
								?>
724
									<option value="<?=$ct;?>"<?=$selected;?>><?=$ctdesc;?></option>
725
								<?php endforeach; ?>
726
								</select>
727
								<br/>
728
								<?=gettext("Type of certificate to generate. Used for placing restrictions on the usage of the generated certificate.");?>
729
							</td>
730
						</tr>
731
						<tr>
732
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
733
							<td width="78%" class="vtable">
734
								<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
735
								<?=gettext("days");?>
736
							</td>
737
						</tr>
738
						<tr>
739
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
740
							<td width="78%" class="vtable">
741
								<table border="0" cellspacing="0" cellpadding="2" summary="name">
742
									<tr>
743
										<td align="right"><?=gettext("Country Code");?> : &nbsp;</td>
744
										<td align="left">
745
											<input name="dn_country" type="text" class="formfld unknown" maxlength="2" size="2" value="<?=htmlspecialchars($pconfig['dn_country']);?>"/>
746
										</td>
747
									</tr>
748
									<tr>
749
										<td align="right"><?=gettext("State or Province");?> : &nbsp;</td>
750
										<td align="left">
751
											<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>"/>
752
										</td>
753
									</tr>
754
									<tr>
755
										<td align="right"><?=gettext("City");?> : &nbsp;</td>
756
										<td align="left">
757
											<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>"/>
758
										</td>
759
									</tr>
760
									<tr>
761
										<td align="right"><?=gettext("Organization");?> : &nbsp;</td>
762
										<td align="left">
763
											<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>"/>
764
										</td>
765
									</tr>
766
									<tr>
767
										<td align="right"><?=gettext("Email Address");?> : &nbsp;</td>
768
										<td align="left">
769
											<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/>
770
											&nbsp;
771
											<em>ex:</em>
772
											&nbsp;
773
											<?=gettext("webadmin@mycompany.com");?>
774
										</td>
775
									</tr>
776
									<tr>
777
										<td align="right"><?=gettext("Common Name");?> : &nbsp;</td>
778
										<td align="left">
779
											<?php
780
											if ($a_user && empty($pconfig['dn_commonname']))
781
												$pconfig['dn_commonname'] = $a_user[$userid]['name'];
782
											?>
783
											<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/>
784
											&nbsp;
785
											<em>ex:</em>
786
											&nbsp;
787
											<?=gettext("www.example.com");?>
788
										</td>
789
									</tr>
790
									<tr>
791
										<td align="right"><?=gettext("Alternative Names");?> : &nbsp;</td>
792
										<td align="left">
793
											<table id="altNametable">
794
											<thead>
795
											<tr>
796
												<th><div id="onecolumn"><?=gettext("Type");?></div></th>
797
												<th><div id="twocolumn"><?=gettext("Value");?></div></th>
798
											</tr>
799
											</thead>
800
											<tbody>
801
											<?php
802
												$counter = 0;
803
												if($pconfig['altnames']['item']):
804
												foreach($pconfig['altnames']['item'] as $item):
805
													$type = $item['type'];
806
													$value = $item['value'];
807
											?>
808
											<tr>
809
												<td>
810
												<input autocomplete="off" name="altname_type<?php echo $counter; ?>" type="text" class="formfld unknown" id="altname_type<?php echo $counter; ?>" size="20" value="<?=htmlspecialchars($type);?>" />
811
												</td>
812
												<td>
813
												<input autocomplete="off" name="altname_value<?php echo $counter; ?>" type="text" class="formfld unknown" id="altname_value<?php echo $counter; ?>" size="20" value="<?=htmlspecialchars($value);?>" />
814
												</td>
815
												<td>
816
												<a onclick="removeRow(this); return false;" href="#"><img border="0" src="/themes/<?echo $g['theme'];?>/images/icons/icon_x.gif" alt="" title="<?=gettext("remove this entry"); ?>" /></a>
817
												</td>
818
											</tr>
819
											<?php
820
													$counter++;
821
												endforeach;
822
												endif;
823
											?>
824
											<tr><td>&nbsp;</td></tr>
825
											</tbody>
826
											</table>
827
											<a onclick="javascript:addRowTo('altNametable', 'formfldalias'); return false;" href="#">
828
												<img border="0" src="/themes/<?= $g['theme']; ?>/images/icons/icon_plus.gif" alt="" title="<?=gettext("add another entry");?>" />
829
											</a>
830
											<script type="text/javascript">
831
											//<![CDATA[
832
												field_counter_js = 3;
833
												rows = 1;
834
												totalrows = <?php echo $counter; ?>;
835
												loaded = <?php echo $counter; ?>;
836
											//]]>
837
											</script>
838
											<br/>NOTE: Type must be one of DNS (FQDN or Hostname), IP (IP address), URI, or email.
839
										</td>
840
									</tr>
841
								</table>
842
							</td>
843
						</tr>
844

    
845
					<?php endif; ?>
846

    
847
					</table>
848

    
849
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="external" summary="external">
850
						<tr>
851
							<td colspan="2" class="list" height="12"></td>
852
						</tr>
853
						<tr>
854
							<td colspan="2" valign="top" class="listtopic"><?=gettext("External Signing Request");?></td>
855
						</tr>
856
						<tr>
857
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
858
							<td width="78%" class="vtable">
859
								<select name='csr_keylen' class="formselect">
860
								<?php
861
									if (!isset($pconfig['csr_keylen']) && isset($pconfig['csr_keylen']))
862
										$pconfig['csr_keylen'] = $pconfig['csr_keylen'];
863
									foreach( $cert_keylens as $len):
864
									$selected = "";
865
									if ($pconfig['csr_keylen'] == $len)
866
										$selected = " selected=\"selected\"";
867
								?>
868
									<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
869
								<?php endforeach; ?>
870
								</select>
871
								bits
872
							</td>
873
						</tr>
874
						<tr>
875
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Digest Algorithm");?></td>
876
							<td width="78%" class="vtable">
877
								<select name='csr_digest_alg' id='csr_digest_alg' class="formselect">
878
								<?php
879
									foreach( $openssl_digest_algs as $csr_digest_alg):
880
									$selected = "";
881
									if ($pconfig['csr_digest_alg'] == $csr_digest_alg)
882
										$selected = " selected=\"selected\"";
883
								?>
884
									<option value="<?=$csr_digest_alg;?>"<?=$selected;?>><?=strtoupper($csr_digest_alg);?></option>
885
								<?php endforeach; ?>
886
								</select>
887
								<br/><?= gettext("NOTE: It is recommended to use an algorithm stronger than SHA1 when possible.") ?>
888
							</td>
889
						</tr>
890
						<tr>
891
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
892
							<td width="78%" class="vtable">
893
								<table border="0" cellspacing="0" cellpadding="2" summary="name">
894
									<tr>
895
										<td align="right"><?=gettext("Country Code");?> : &nbsp;</td>
896
										<td align="left">
897
											<select name='csr_dn_country' class="formselect">
898
											<?php
899
											foreach( $dn_cc as $cc){
900
												$selected = "";
901
												if ($pconfig['csr_dn_country'] == $cc)
902
													$selected = " selected=\"selected\"";
903
												print "<option value=\"$cc\"$selected>$cc</option>";
904
												}
905
											?>
906
											</select>
907
										</td>
908
									</tr>
909
									<tr>
910
										<td align="right"><?=gettext("State or Province");?> : &nbsp;</td>
911
										<td align="left">
912
											<input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_state']);?>" />
913
											&nbsp;
914
											<em>ex:</em>
915
											&nbsp;
916
											<?=gettext("Texas");?>
917
										</td>
918
									</tr>
919
									<tr>
920
										<td align="right"><?=gettext("City");?> : &nbsp;</td>
921
										<td align="left">
922
											<input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_city']);?>" />
923
											&nbsp;
924
											<em>ex:</em>
925
											&nbsp;
926
											<?=gettext("Austin");?>
927
										</td>
928
									</tr>
929
									<tr>
930
										<td align="right"><?=gettext("Organization");?> : &nbsp;</td>
931
										<td align="left">
932
											<input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_organization']);?>" />
933
											&nbsp;
934
											<em>ex:</em>
935
											&nbsp;
936
											<?=gettext("My Company Inc.");?>
937
										</td>
938
									</tr>
939
									<tr>
940
										<td align="right"><?=gettext("Email Address");?> : &nbsp;</td>
941
										<td align="left">
942
											<input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_email']);?>"/>
943
											&nbsp;
944
											<em>ex:</em>
945
											&nbsp;
946
											<?=gettext("webadmin@mycompany.com");?>
947
										</td>
948
									</tr>
949
									<tr>
950
										<td align="right"><?=gettext("Common Name");?> : &nbsp;</td>
951
										<td align="left">
952
											<input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_commonname']);?>"/>
953
											&nbsp;
954
											<em>ex:</em>
955
											&nbsp;
956
											<?=gettext("www.example.com");?>
957
										</td>
958
									</tr>
959
								</table>
960
							</td>
961
						</tr>
962
					</table>
963

    
964
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing" summary="existing">
965
						<tr>
966
							<td colspan="2" class="list" height="12"></td>
967
						</tr>
968
						<tr>
969
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Choose an Existing Certificate");?></td>
970
						</tr>
971
						<tr>
972
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Existing Certificates");?></td>
973
							<td width="78%" class="vtable">
974
								<?php if (isset($userid) && $a_user): ?>
975
								<input name="userid" type="hidden" value="<?=htmlspecialchars($userid);?>" />
976
								<?php endif;?>
977
								<select name='certref' class="formselect">
978
								<?php
979
									foreach ($config['cert'] as $cert):
980
										$selected = "";
981
										$caname = "";
982
										$inuse = "";
983
										$revoked = "";
984
										if (isset($userid) && in_array($cert['refid'], $config['system']['user'][$userid]['cert']))
985
											continue;
986
										$ca = lookup_ca($cert['caref']);
987
										if ($ca)
988
											$caname = " (CA: {$ca['descr']})";
989
										if ($pconfig['certref'] == $cert['refid'])
990
											$selected = " selected=\"selected\"";
991
										if (cert_in_use($cert['refid']))
992
											$inuse = " *In Use";
993
											if (is_cert_revoked($cert))
994
											$revoked = " *Revoked";
995
								?>
996
									<option value="<?=$cert['refid'];?>"<?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
997
								<?php endforeach; ?>
998
								</select>
999
							</td>
1000
						</tr>
1001
					</table>
1002

    
1003
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="save">
1004
						<tr>
1005
							<td width="22%" valign="top">&nbsp;</td>
1006
							<td width="78%">
1007
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
1008
								<?php if (isset($id) && $a_cert[$id]): ?>
1009
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1010
								<?php endif;?>
1011
							</td>
1012
						</tr>
1013
					</table>
1014
				</form>
1015

    
1016
				<?php elseif ($act == "csr" || (($_POST['save'] == gettext("Update")) && $input_errors)):?>
1017

    
1018
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
1019
					<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="name">
1020
						<tr>
1021
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
1022
							<td width="78%" class="vtable">
1023
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
1024
							</td>
1025
						</tr>
1026
						<tr>
1027
							<td colspan="2" class="list" height="12"></td>
1028
						</tr>
1029
						<tr>
1030
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Complete Signing Request");?></td>
1031
						</tr>
1032

    
1033
						<tr>
1034
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Signing request data");?></td>
1035
							<td width="78%" class="vtable">
1036
								<textarea name="csr" id="csr" cols="65" rows="7" class="formfld_cert" readonly="readonly"><?=htmlspecialchars($pconfig['csr']);?></textarea>
1037
								<br/>
1038
								<?=gettext("Copy the certificate signing data from here and forward it to your certificate authority for signing.");?></td>
1039
							</td>
1040
						</tr>
1041
						<tr>
1042
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Final certificate data");?></td>
1043
							<td width="78%" class="vtable">
1044
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea>
1045
								<br/>
1046
								<?=gettext("Paste the certificate received from your certificate authority here.");?></td>
1047
							</td>
1048
						</tr>
1049
						<tr>
1050
							<td width="22%" valign="top">&nbsp;</td>
1051
							<td width="78%">
1052
								<?php /* if ( isset($subject_mismatch) && $subject_mismatch === true): ?>
1053
								<input id="ignoresubjectmismatch" name="ignoresubjectmismatch" type="checkbox" class="formbtn" value="yes" />
1054
								<label for="ignoresubjectmismatch"><strong><?=gettext("Ignore certificate subject mismatch"); ?></strong></label><br />
1055
								<?php echo gettext("Warning: Using this option may create an " .
1056
								"invalid certificate.  Check this box to disable the request -> " .
1057
								"response subject verification. ");
1058
								?><br/>
1059
								<?php endif; */ ?>
1060
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Update");?>" />
1061
								<?php if (isset($id) && $a_cert[$id]): ?>
1062
								<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" />
1063
								<input name="act" type="hidden" value="csr" />
1064
								<?php endif;?>
1065
							</td>
1066
						</tr>
1067
					</table>
1068
				</form>
1069

    
1070
				<?php else:?>
1071

    
1072
				<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="details">
1073
					<tr>
1074
						<td width="15%" class="listhdrr"><?=gettext("Name");?></td>
1075
						<td width="15%" class="listhdrr"><?=gettext("Issuer");?></td>
1076
						<td width="40%" class="listhdrr"><?=gettext("Distinguished Name");?></td>
1077
						<td width="10%" class="listhdrr"><?=gettext("In Use");?></td>
1078
						<td width="10%" class="list"></td>
1079
					</tr>
1080
					<?php
1081
						$i = 0;
1082
						foreach($a_cert as $cert):
1083
							$name = htmlspecialchars($cert['descr']);
1084
							
1085
							if ($cert['crt']) {
1086
								$subj = cert_get_subject($cert['crt']);
1087
								$issuer = cert_get_issuer($cert['crt']);
1088
								$purpose = cert_get_purpose($cert['crt']);
1089
								list($startdate, $enddate) = cert_get_dates($cert['crt']);
1090
								if($subj==$issuer)
1091
								  $caname = "<em>" . gettext("self-signed") . "</em>";
1092
								else
1093
							    $caname = "<em>" . gettext("external"). "</em>";
1094
							  $subj = htmlspecialchars($subj);
1095
							}
1096

    
1097
							if ($cert['csr']) {
1098
								$subj = htmlspecialchars(csr_get_subject($cert['csr']));
1099
								$caname = "<em>" . gettext("external - signature pending") . "</em>";
1100
							}
1101

    
1102
							$ca = lookup_ca($cert['caref']);
1103
							if ($ca)
1104
								$caname = $ca['descr'];
1105

    
1106
							if($cert['prv'])
1107
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
1108
							else
1109
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
1110
					?>
1111
					<tr>
1112
						<td class="listlr">
1113
							<table border="0" cellpadding="0" cellspacing="0" summary="icon">
1114
								<tr>
1115
									<td align="left" valign="middle">
1116
										<img src="<?=$certimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
1117
									</td>
1118
									<td align="left" valign="middle">
1119
										<?=$name;?>
1120
									</td>
1121
								</tr>
1122
								<tr><td>&nbsp;</td></tr>
1123
								<?php if ($cert['type']): ?>
1124
								<tr><td colspan="2"><em><?php echo $cert_types[$cert['type']]; ?></em></td></tr>
1125
								<?php endif; ?>
1126
								<?php if (is_array($purpose)): ?>
1127
								<tr><td colspan="2">
1128
									CA: <?php echo $purpose['ca']; ?>,
1129
									Server: <?php echo $purpose['server']; ?>
1130
								</td></tr>
1131
								<?php endif; ?>
1132
							</table>
1133
						</td>
1134
						<td class="listr"><?=$caname;?>&nbsp;</td>
1135
						<td class="listr"><?=$subj;?>&nbsp;<br />
1136
							<table width="100%" style="font-size: 9px" summary="valid">
1137
								<tr>
1138
									<td width="10%">&nbsp;</td>
1139
									<td width="20%"><?=gettext("Valid From")?>:</td>
1140
									<td width="70%"><?= $startdate ?></td>
1141
								</tr>
1142
								<tr>
1143
									<td>&nbsp;</td>
1144
									<td><?=gettext("Valid Until")?>:</td>
1145
									<td><?= $enddate ?></td>
1146
								</tr>
1147
							</table>
1148
						</td>
1149
						<td class="listr">
1150
							<?php if (is_cert_revoked($cert)): ?>
1151
							<b>Revoked</b><br/>
1152
							<?php endif; ?>
1153
							<?php if (is_webgui_cert($cert['refid'])): ?>
1154
							webConfigurator<br/>
1155
							<?php endif; ?>
1156
							<?php if (is_user_cert($cert['refid'])): ?>
1157
							User Cert<br/>
1158
							<?php endif; ?>
1159
							<?php if (is_openvpn_server_cert($cert['refid'])): ?>
1160
							OpenVPN Server<br/>
1161
							<?php endif; ?>
1162
							<?php if (is_openvpn_client_cert($cert['refid'])): ?>
1163
							OpenVPN Client<br/>
1164
							<?php endif; ?>
1165
							<?php if (is_ipsec_cert($cert['refid'])): ?>
1166
							IPsec Tunnel<br/>
1167
							<?php endif; ?>
1168
							<?php if (is_captiveportal_cert($cert['refid'])): ?>
1169
							Captive Portal<br/>
1170
							<?php endif; ?>
1171
						</td>
1172
						<td valign="middle" class="list nowrap">
1173
							<a href="system_certmanager.php?act=exp&amp;id=<?=$i;?>">
1174
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert");?>" alt="<?=gettext("export ca");?>" width="17" height="17" border="0" />
1175
							</a>
1176
							<a href="system_certmanager.php?act=key&amp;id=<?=$i;?>">
1177
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export key");?>" alt="<?=gettext("export ca");?>" width="17" height="17" border="0" />
1178
							</a>
1179
							<a href="system_certmanager.php?act=p12&amp;id=<?=$i;?>">
1180
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert+key in .p12");?>" alt="<?=gettext("export cert+key in .p12");?>" width="17" height="17" border="0" />
1181
							</a>
1182
							<?php	if (!cert_in_use($cert['refid'])): ?>
1183
							<a href="system_certmanager.php?act=del&amp;id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate?");?>')">
1184
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete cert");?>" alt="<?=gettext("delete cert");?>" width="17" height="17" border="0" />
1185
							</a>
1186
							<?php	endif; ?>
1187
							<?php	if ($cert['csr']): ?>
1188
							&nbsp;
1189
								<a href="system_certmanager.php?act=csr&amp;id=<?=$i;?>">
1190
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("update csr");?>" alt="<?=gettext("update csr");?>" width="17" height="17" border="0" />
1191
							</a>
1192
							<?php	endif; ?>
1193
						</td>
1194
					</tr>
1195
					<?php
1196
							$i++;
1197
						endforeach;
1198
					?>
1199
					<tr>
1200
						<td class="list" colspan="4"></td>
1201
						<td class="list">
1202
							<a href="system_certmanager.php?act=new">
1203
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add or import certificate");?>" alt="<?=gettext("add certificate");?>" width="17" height="17" border="0" />
1204
							</a>
1205
						</td>
1206
					</tr>
1207
					<tr>
1208
						<td>&nbsp;</td>
1209
						<td colspan="3"><?=gettext("Note: You can only delete a certificate if it is not currently in use.");?></td>
1210
					</tr>
1211
				</table>
1212

    
1213
				<?php endif; ?>
1214

    
1215
			</div>
1216
		</td>
1217
	</tr>
1218
</table>
1219
<?php include("fend.inc");?>
1220
<script type="text/javascript">
1221
//<![CDATA[
1222

    
1223
method_change();
1224
internalca_change();
1225

    
1226
//]]>
1227
</script>
1228

    
1229
</body>
1230
</html>
(204-204/246)