Project

General

Profile

Download (44.1 KB) Statistics
| Branch: | Tag: | Revision:
1
<?php
2
/*
3
	system_certmanager.php
4

    
5
	Copyright (C) 2008 Shrew Soft Inc.
6
	Copyright (C) 2013-2015 Electric Sheep Fencing, LP
7
	All rights reserved.
8

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
163
	$exp_name = urlencode("{$a_cert[$id]['descr']}.p12");
164
	$args = array();
165
	$args['friendly_name'] = $a_cert[$id]['descr'];
166

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
406
			if ($userid) {
407
				post_redirect("system_usermanager.php", array('act' => 'edit', 'userid' => $userid));
408
				exit;
409
			}
410
		}
411
	}
412

    
413
	if ($_POST['save'] == gettext("Update")) {
414
		unset($input_errors);
415
		$pconfig = $_POST;
416

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

    
423
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
424

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

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

    
451
		/* save modifications */
452
		if (!$input_errors) {
453

    
454
			$cert = $a_cert[$id];
455

    
456
			$cert['descr'] = $pconfig['descr'];
457

    
458
			csr_complete($cert, $pconfig['cert']);
459

    
460
			$a_cert[$id] = $cert;
461

    
462
			write_config();
463

    
464
			pfSenseHeader("system_certmanager.php");
465
		}
466
	}
467
}
468

    
469
include("head.inc");
470
?>
471

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

    
477
function method_change() {
478

    
479
<?php
480
	if ($internal_ca_count)
481
		$submit_style = "";
482
	else
483
		$submit_style = "none";
484
?>
485

    
486
	method = document.iform.method.selectedIndex;
487

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

    
524
<?php if ($internal_ca_count): ?>
525
function internalca_change() {
526

    
527
	index = document.iform.caref.selectedIndex;
528
	caref = document.iform.caref[index].value;
529

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

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

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

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

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

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

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

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

    
662
						<?php if (!$internal_ca_count): ?>
663

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

    
672
						<?php else: ?>
673

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

    
854
					<?php endif; ?>
855

    
856
					</table>
857

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

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

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

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

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

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

    
1079
				<?php else:?>
1080

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

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

    
1111
							$ca = lookup_ca($cert['caref']);
1112
							if ($ca)
1113
								$caname = $ca['descr'];
1114

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

    
1222
				<?php endif; ?>
1223

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

    
1232
method_change();
1233
internalca_change();
1234

    
1235
//]]>
1236
</script>
1237

    
1238
</body>
1239
</html>
(213-213/256)