Project

General

Profile

Download (43.7 KB) Statistics
| Branch: | Tag: | Revision:
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
$userid = $_GET['userid'];
60
if (isset($_POST['userid']))
61
	$userid = $_POST['userid'];
62
if (is_numeric($userid)) {
63
	$cert_methods["existing"] = gettext("Choose an existing certificate");
64
	if (!is_array($config['system']['user']))
65
		$config['system']['user'] = array();
66
	$a_user =& $config['system']['user'];
67
}
68

    
69
$id = $_GET['id'];
70
if (isset($_POST['id']))
71
	$id = $_POST['id'];
72

    
73
if (!is_array($config['ca']))
74
	$config['ca'] = array();
75

    
76
$a_ca =& $config['ca'];
77

    
78
if (!is_array($config['cert']))
79
	$config['cert'] = array();
80

    
81
$a_cert =& $config['cert'];
82

    
83
$internal_ca_count = 0;
84
foreach ($a_ca as $ca)
85
	if ($ca['prv'])	
86
		$internal_ca_count++;
87

    
88
$act = $_GET['act'];
89
if ($_POST['act'])
90
	$act = $_POST['act'];
91

    
92
if ($act == "del") {
93

    
94
	if (!isset($a_cert[$id])) {
95
		pfSenseHeader("system_certmanager.php");
96
		exit;
97
	}
98

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

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

    
117
if ($act == "exp") {
118

    
119
	if (!$a_cert[$id]) {
120
		pfSenseHeader("system_certmanager.php");
121
		exit;
122
	}
123

    
124
	$exp_name = urlencode("{$a_cert[$id]['descr']}.crt");
125
	$exp_data = base64_decode($a_cert[$id]['crt']);
126
	$exp_size = strlen($exp_data);
127

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

    
135
if ($act == "key") {
136

    
137
	if (!$a_cert[$id]) {
138
		pfSenseHeader("system_certmanager.php");
139
		exit;
140
	}
141

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

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

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

    
159
	$exp_name = urlencode("{$a_cert[$id]['descr']}.p12");
160
	$args = array();
161
	$args['friendly_name'] = $a_cert[$id]['descr'];
162

    
163
	$ca = lookup_ca($a_cert[$id]['caref']);
164
	if ($ca)
165
		$args['extracerts'] = openssl_x509_read(base64_decode($ca['crt']));
166

    
167
	$res_crt = openssl_x509_read(base64_decode($a_cert[$id]['crt']));
168
	$res_key = openssl_pkey_get_private(array(0 => base64_decode($a_cert[$id]['prv']) , 1 => ""));
169

    
170
	$exp_data = "";
171
	openssl_pkcs12_export($res_crt, $exp_data, $res_key, null, $args);
172
	$exp_size = strlen($exp_data);
173

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

    
181
if ($act == "csr") {
182

    
183
	if (!$a_cert[$id]) {
184
		pfSenseHeader("system_certmanager.php");
185
		exit;
186
	}
187

    
188
	$pconfig['descr'] = $a_cert[$id]['descr'];
189
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
190
}
191

    
192
if ($_POST) {
193
	if ($_POST['save'] == gettext("Save")) {
194
		$input_errors = array();
195
		$pconfig = $_POST;
196

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

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

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

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

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

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

    
294
			/* Make sure we do not have invalid characters in the fields for the certificate */
295
			for ($i = 0; $i < count($reqdfields); $i++) {
296
				if (preg_match('/email/', $reqdfields[$i])){ /* dn_email or csr_dn_name */
297
				 	if (preg_match("/[\!\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST["$reqdfields[$i]"]))
298
						array_push($input_errors, "The field 'Distinguished name Email Address' contains invalid characters.");
299
				}else if (preg_match('/commonname/', $reqdfields[$i])){ /* dn_commonname or csr_dn_commonname */
300
					if (preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\"\']/", $_POST["$reqdfields[$i]"]))
301
						array_push($input_errors, "The field 'Distinguished name Common Name' contains invalid characters.");
302
				}else if (($reqdfields[$i] != "descr") && preg_match("/[\!\@\#\$\%\^\(\)\~\?\>\<\&\/\\\,\.\"\']/", $_POST["$reqdfields[$i]"]))
303
					array_push($input_errors, "The field '" . $reqdfieldsn[$i] . "' contains invalid characters.");
304
			}
305
			
306
			if (isset($_POST["keylen"]) && !in_array($_POST["keylen"], $cert_keylens))
307
				array_push($input_errors, gettext("Please select a valid Key Length."));
308
			if (!in_array($_POST["digest_alg"], $openssl_digest_algs))
309
				array_push($input_errors, gettext("Please select a valid Digest Algorithm."));
310
				
311
			if (isset($_POST["csr_keylen"]) && !in_array($_POST["csr_keylen"], $cert_keylens))
312
				array_push($input_errors, gettext("Please select a valid Key Length."));
313
			if (!in_array($_POST["csr_digest_alg"], $openssl_digest_algs))
314
				array_push($input_errors, gettext("Please select a valid Digest Algorithm."));
315
		}
316

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

    
323
		/* save modifications */
324
		if (!$input_errors) {
325

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

    
336
				$cert['descr'] = $pconfig['descr'];
337

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

    
340
				if ($pconfig['method'] == "import")
341
					cert_import($cert, $pconfig['cert'], $pconfig['key']);
342

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

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

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

    
399
			if (!$input_errors)
400
				write_config();
401

    
402
			if ($userid)
403
				pfSenseHeader("system_usermanager.php?act=edit&id={$userid}");
404
		}
405
	}
406

    
407
	if ($_POST['save'] == gettext("Update")) {
408
		unset($input_errors);
409
		$pconfig = $_POST;
410

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

    
417
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, $input_errors);
418

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

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

    
445
		/* save modifications */
446
		if (!$input_errors) {
447

    
448
			$cert = $a_cert[$id];
449

    
450
			$cert['descr'] = $pconfig['descr'];
451

    
452
			csr_complete($cert, $pconfig['cert']);
453

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

    
456
			write_config();
457

    
458
			pfSenseHeader("system_certmanager.php");
459
		}
460
	}
461
}
462

    
463
include("head.inc");
464
?>
465

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

    
471
function method_change() {
472

    
473
<?php
474
	if ($internal_ca_count)
475
		$submit_style = "";
476
	else
477
		$submit_style = "none";
478
?>
479

    
480
	method = document.iform.method.selectedIndex;
481

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

    
518
<?php if ($internal_ca_count): ?>
519
function internalca_change() {
520

    
521
	index = document.iform.caref.selectedIndex;
522
	caref = document.iform.caref[index].value;
523

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

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

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

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

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

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

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

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

    
656
						<?php if (!$internal_ca_count): ?>
657

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

    
666
						<?php else: ?>
667

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

    
848
					<?php endif; ?>
849

    
850
					</table>
851

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

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

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

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

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

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

    
1073
				<?php else:?>
1074

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

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

    
1105
							$ca = lookup_ca($cert['caref']);
1106
							if ($ca)
1107
								$caname = $ca['descr'];
1108

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

    
1216
				<?php endif; ?>
1217

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

    
1226
method_change();
1227
internalca_change();
1228

    
1229
//]]>
1230
</script>
1231

    
1232
</body>
1233
</html>
(204-204/246)