Projet

Général

Profil

Télécharger (44,1 ko) Statistiques
| Branche: | Tag: | Révision:

univnautes / usr / local / www / system_certmanager.php @ b3733e10

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
	$args = array();
164
	$args['friendly_name'] = $a_cert[$id]['descr'];
165

    
166
	$ca = lookup_ca($a_cert[$id]['caref']);
167
	if ($ca)
168
		$args['extracerts'] = openssl_x509_read(base64_decode($ca['crt']));
169

    
170
	$res_crt = openssl_x509_read(base64_decode($a_cert[$id]['crt']));
171
	$res_key = openssl_pkey_get_private(array(0 => base64_decode($a_cert[$id]['prv']) , 1 => ""));
172

    
173
	$exp_data = "";
174
	openssl_pkcs12_export($res_crt, $exp_data, $res_key, null, $args);
175
	$exp_size = strlen($exp_data);
176

    
177
	header("Content-Type: application/octet-stream");
178
	header("Content-Disposition: attachment; filename={$exp_name}");
179
	header("Content-Length: $exp_size");
180
	echo $exp_data;
181
	exit;
182
}
183

    
184
if ($act == "csr") {
185

    
186
	if (!$a_cert[$id]) {
187
		pfSenseHeader("system_certmanager.php");
188
		exit;
189
	}
190

    
191
	$pconfig['descr'] = $a_cert[$id]['descr'];
192
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
193
}
194

    
195
if ($_POST) {
196
	if ($_POST['save'] == gettext("Save")) {
197
		$input_errors = array();
198
		$pconfig = $_POST;
199

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

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

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

    
245
		if ($pconfig['method'] == "existing") {
246
			$reqdfields = array("certref");
247
			$reqdfieldsn = array(gettext("Existing Certificate Choice"));
248
		}
249

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

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

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

    
309
			if (($pconfig['method'] != "external") && isset($_POST["keylen"]) && !in_array($_POST["keylen"], $cert_keylens))
310
				array_push($input_errors, gettext("Please select a valid Key Length."));
311
			if (($pconfig['method'] != "external") && !in_array($_POST["digest_alg"], $openssl_digest_algs))
312
				array_push($input_errors, gettext("Please select a valid Digest Algorithm."));
313
				
314
			if (($pconfig['method'] == "external") && isset($_POST["csr_keylen"]) && !in_array($_POST["csr_keylen"], $cert_keylens))
315
				array_push($input_errors, gettext("Please select a valid Key Length."));
316
			if (($pconfig['method'] == "external") && !in_array($_POST["csr_digest_alg"], $openssl_digest_algs))
317
				array_push($input_errors, gettext("Please select a valid Digest Algorithm."));
318
		}
319

    
320
		/* if this is an AJAX caller then handle via JSON */
321
		if (isAjax() && is_array($input_errors)) {
322
			input_errors2Ajax($input_errors);
323
			exit;
324
		}
325

    
326
		/* save modifications */
327
		if (!$input_errors) {
328

    
329
			if ($pconfig['method'] == "existing") {
330
				$cert = lookup_cert($pconfig['certref']);
331
				if ($cert && $a_user)
332
					$a_user[$userid]['cert'][] = $cert['refid'];
333
			} else {
334
				$cert = array();
335
				$cert['refid'] = uniqid();
336
				if (isset($id) && $a_cert[$id])
337
					$cert = $a_cert[$id];
338

    
339
				$cert['descr'] = $pconfig['descr'];
340

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

    
343
				if ($pconfig['method'] == "import")
344
					cert_import($cert, $pconfig['cert'], $pconfig['key']);
345

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

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

    
394
				if (isset($id) && $a_cert[$id])
395
					$a_cert[$id] = $cert;
396
				else
397
					$a_cert[] = $cert;
398
				if (isset($a_user) && isset($userid))
399
					$a_user[$userid]['cert'][] = $cert['refid'];
400
			}
401

    
402
			if (!$input_errors)
403
				write_config();
404

    
405
			if ($userid)
406
				pfSenseHeader("system_usermanager.php?act=edit&amp;id={$userid}");
407
		}
408
	}
409

    
410
	if ($_POST['save'] == gettext("Update")) {
411
		unset($input_errors);
412
		$pconfig = $_POST;
413

    
414
		/* input validation */
415
		$reqdfields = explode(" ", "descr cert");
416
		$reqdfieldsn = array(
417
			gettext("Descriptive name"),
418
			gettext("Final Certificate data"));
419

    
420
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
421

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

    
442
		/* if this is an AJAX caller then handle via JSON */
443
		if (isAjax() && is_array($input_errors)) {
444
			input_errors2Ajax($input_errors);
445
			exit;
446
		}
447

    
448
		/* save modifications */
449
		if (!$input_errors) {
450

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

    
453
			$cert['descr'] = $pconfig['descr'];
454

    
455
			csr_complete($cert, $pconfig['cert']);
456

    
457
			$a_cert[$id] = $cert;
458

    
459
			write_config();
460

    
461
			pfSenseHeader("system_certmanager.php");
462
		}
463
	}
464
}
465

    
466
include("head.inc");
467
?>
468

    
469
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
470
<?php include("fbegin.inc"); ?>
471
<script type="text/javascript">
472
//<![CDATA[
473

    
474
function method_change() {
475

    
476
<?php
477
	if ($internal_ca_count)
478
		$submit_style = "";
479
	else
480
		$submit_style = "none";
481
?>
482

    
483
	method = document.iform.method.selectedIndex;
484

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

    
521
<?php if ($internal_ca_count): ?>
522
function internalca_change() {
523

    
524
	index = document.iform.caref.selectedIndex;
525
	caref = document.iform.caref[index].value;
526

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

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

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

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

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

    
625
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="import" summary="import">
626
						<tr>
627
							<td colspan="2" class="list" height="12"></td>
628
						</tr>
629
						<tr>
630
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Import Certificate");?></td>
631
						</tr>
632

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

    
651
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal" summary="internal">
652
						<tr>
653
							<td colspan="2" class="list" height="12"></td>
654
						</tr>
655
						<tr>
656
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate");?></td>
657
						</tr>
658

    
659
						<?php if (!$internal_ca_count): ?>
660

    
661
						<tr>
662
							<td colspan="2" align="center" class="vtable">
663
								<?=gettext("No internal Certificate Authorities have been defined. You must");?>
664
								<a href="system_camanager.php?act=new&amp;method=internal"><?=gettext("create");?></a>
665
								<?=gettext("an internal CA before creating an internal certificate.");?>
666
							</td>
667
						</tr>
668

    
669
						<?php else: ?>
670

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

    
851
					<?php endif; ?>
852

    
853
					</table>
854

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

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

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

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

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

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

    
1076
				<?php else:?>
1077

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

    
1103
							if ($cert['csr']) {
1104
								$subj = htmlspecialchars(csr_get_subject($cert['csr']));
1105
								$caname = "<em>" . gettext("external - signature pending") . "</em>";
1106
							}
1107

    
1108
							$ca = lookup_ca($cert['caref']);
1109
							if ($ca)
1110
								$caname = $ca['descr'];
1111

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

    
1219
				<?php endif; ?>
1220

    
1221
			</div>
1222
		</td>
1223
	</tr>
1224
</table>
1225
<?php include("fend.inc");?>
1226
<script type="text/javascript">
1227
//<![CDATA[
1228

    
1229
method_change();
1230
internalca_change();
1231

    
1232
//]]>
1233
</script>
1234

    
1235
</body>
1236
</html>
(211-211/254)