Project

General

Profile

Download (43.6 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

    
161
	$res_crt = openssl_x509_read(base64_decode($a_cert[$id]['crt']));
162
	$res_key = openssl_pkey_get_private(array(0 => base64_decode($a_cert[$id]['prv']) , 1 => ""));
163

    
164
	$exp_data = "";
165
	openssl_pkcs12_export($res_crt, $exp_data, $res_key, null);
166
	$exp_size = strlen($exp_data);
167

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

    
175
if ($act == "csr") {
176

    
177
	if (!$a_cert[$id]) {
178
		pfSenseHeader("system_certmanager.php");
179
		exit;
180
	}
181

    
182
	$pconfig['descr'] = $a_cert[$id]['descr'];
183
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
184
}
185

    
186
if ($_POST) {
187
	if ($_POST['save'] == gettext("Save")) {
188
		$input_errors = array();
189
		$pconfig = $_POST;
190

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

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

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

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

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

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

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

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

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

    
317
		/* save modifications */
318
		if (!$input_errors) {
319

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

    
330
				$cert['descr'] = $pconfig['descr'];
331

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

    
334
				if ($pconfig['method'] == "import")
335
					cert_import($cert, $pconfig['cert'], $pconfig['key']);
336

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

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

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

    
393
			if (!$input_errors)
394
				write_config();
395

    
396
			if ($userid)
397
				pfSenseHeader("system_usermanager.php?act=edit&id={$userid}");
398
		}
399
	}
400

    
401
	if ($_POST['save'] == gettext("Update")) {
402
		unset($input_errors);
403
		$pconfig = $_POST;
404

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

    
411
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
412

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

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

    
439
		/* save modifications */
440
		if (!$input_errors) {
441

    
442
			$cert = $a_cert[$id];
443

    
444
			$cert['descr'] = $pconfig['descr'];
445

    
446
			csr_complete($cert, $pconfig['cert']);
447

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

    
450
			write_config();
451

    
452
			pfSenseHeader("system_certmanager.php");
453
		}
454
	}
455
}
456

    
457
include("head.inc");
458
?>
459

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

    
465
function method_change() {
466

    
467
<?php
468
	if ($internal_ca_count)
469
		$submit_style = "";
470
	else
471
		$submit_style = "none";
472
?>
473

    
474
	method = document.iform.method.selectedIndex;
475

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

    
512
<?php if ($internal_ca_count): ?>
513
function internalca_change() {
514

    
515
	index = document.iform.caref.selectedIndex;
516
	caref = document.iform.caref[index].value;
517

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

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

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

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

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

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

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

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

    
650
						<?php if (!$internal_ca_count): ?>
651

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

    
660
						<?php else: ?>
661

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

    
842
					<?php endif; ?>
843

    
844
					</table>
845

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

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

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

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

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

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

    
1067
				<?php else:?>
1068

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

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

    
1099
							$ca = lookup_ca($cert['caref']);
1100
							if ($ca)
1101
								$caname = $ca['descr'];
1102

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

    
1210
				<?php endif; ?>
1211

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

    
1220
method_change();
1221
internalca_change();
1222

    
1223
//]]>
1224
</script>
1225

    
1226
</body>
1227
</html>
(204-204/246)