Project

General

Profile

Download (42.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 (!$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['csr_keylen'] = "2048";
111
	$pconfig['digest_alg'] = "sha256";
112
	$pconfig['type'] = "user";
113
	$pconfig['lifetime'] = "3650";
114
}
115

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
306
		/* if this is an AJAX caller then handle via JSON */
307
		if (isAjax() && is_array($input_errors)) {
308
			input_errors2Ajax($input_errors);
309
			exit;
310
		}
311

    
312
		/* save modifications */
313
		if (!$input_errors) {
314

    
315
			if ($pconfig['method'] == "existing") {
316
				$cert = lookup_cert($pconfig['certref']);
317
				if ($cert && $a_user)
318
					$a_user[$userid]['cert'][] = $cert['refid'];
319
			} else {
320
				$cert = array();
321
				$cert['refid'] = uniqid();
322
				if (isset($id) && $a_cert[$id])
323
					$cert = $a_cert[$id];
324

    
325
				$cert['descr'] = $pconfig['descr'];
326

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

    
329
				if ($pconfig['method'] == "import")
330
					cert_import($cert, $pconfig['cert'], $pconfig['key']);
331

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

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

    
380
				if (isset($id) && $a_cert[$id])
381
					$a_cert[$id] = $cert;
382
				else
383
					$a_cert[] = $cert;
384
				if (isset($a_user) && isset($userid))
385
					$a_user[$userid]['cert'][] = $cert['refid'];
386
			}
387

    
388
			if (!$input_errors)
389
				write_config();
390

    
391
			if ($userid)
392
				pfSenseHeader("system_usermanager.php?act=edit&id={$userid}");
393
		}
394
	}
395

    
396
	if ($_POST['save'] == gettext("Update")) {
397
		unset($input_errors);
398
		$pconfig = $_POST;
399

    
400
		/* input validation */
401
		$reqdfields = explode(" ", "descr cert");
402
		$reqdfieldsn = array(
403
			gettext("Descriptive name"),
404
			gettext("Final Certificate data"));
405

    
406
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
407

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

    
428
		/* if this is an AJAX caller then handle via JSON */
429
		if (isAjax() && is_array($input_errors)) {
430
			input_errors2Ajax($input_errors);
431
			exit;
432
		}
433

    
434
		/* save modifications */
435
		if (!$input_errors) {
436

    
437
			$cert = $a_cert[$id];
438

    
439
			$cert['descr'] = $pconfig['descr'];
440

    
441
			csr_complete($cert, $pconfig['cert']);
442

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

    
445
			write_config();
446

    
447
			pfSenseHeader("system_certmanager.php");
448
		}
449
	}
450
}
451

    
452
include("head.inc");
453
?>
454

    
455
<body link="#000000" vlink="#000000" alink="#000000" onLoad="<?= $jsevents["body"]["onload"] ?>">
456
<?php include("fbegin.inc"); ?>
457
<script type="text/javascript">
458
<!--
459

    
460
function method_change() {
461

    
462
<?php
463
	if ($internal_ca_count)
464
		$submit_style = "";
465
	else
466
		$submit_style = "none";
467
?>
468

    
469
	method = document.iform.method.selectedIndex;
470

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

    
507
<?php if ($internal_ca_count): ?>
508
function internalca_change() {
509

    
510
	index = document.iform.caref.selectedIndex;
511
	caref = document.iform.caref[index].value;
512

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

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

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

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

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

    
610
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="import">
611
						<tr>
612
							<td colspan="2" class="list" height="12"></td>
613
						</tr>
614
						<tr>
615
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Import Certificate");?></td>
616
						</tr>
617

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

    
636
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal">
637
						<tr>
638
							<td colspan="2" class="list" height="12"></td>
639
						</tr>
640
						<tr>
641
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate");?></td>
642
						</tr>
643

    
644
						<?php if (!$internal_ca_count): ?>
645

    
646
						<tr>
647
							<td colspan="2" align="center" class="vtable">
648
								<?=gettext("No internal Certificate Authorities have been defined. You must");?>
649
								<a href="system_camanager.php?act=new&method=internal"><?=gettext("create");?></a>
650
								<?=gettext("an internal CA before creating an internal certificate.");?>
651
							</td>
652
						</tr>
653

    
654
						<?php else: ?>
655

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

    
833
					<?php endif; ?>
834

    
835
					</table>
836

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

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

    
991
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
992
						<tr>
993
							<td width="22%" valign="top">&nbsp;</td>
994
							<td width="78%">
995
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
996
								<?php if (isset($id) && $a_cert[$id]): ?>
997
								<input name="id" type="hidden" value="<?=$id;?>" />
998
								<?php endif;?>
999
							</td>
1000
						</tr>
1001
					</table>
1002
				</form>
1003

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

    
1006
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
1007
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
1008
						<tr>
1009
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
1010
							<td width="78%" class="vtable">
1011
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
1012
							</td>
1013
						</tr>
1014
						<tr>
1015
							<td colspan="2" class="list" height="12"></td>
1016
						</tr>
1017
						<tr>
1018
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Complete Signing Request");?></td>
1019
						</tr>
1020

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

    
1058
				<?php else:?>
1059

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

    
1085
							if ($cert['csr']) {
1086
								$subj = htmlspecialchars(csr_get_subject($cert['csr']));
1087
								$caname = "<em>" . gettext("external - signature pending") . "</em>";
1088
							}
1089

    
1090
							$ca = lookup_ca($cert['caref']);
1091
							if ($ca)
1092
								$caname = $ca['descr'];
1093

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

    
1201
				<?php endif; ?>
1202

    
1203
			</div>
1204
		</td>
1205
	</tr>
1206
</table>
1207
<?php include("fend.inc");?>
1208
<script type="text/javascript">
1209
<!--
1210

    
1211
method_change();
1212
internalca_change();
1213

    
1214
//-->
1215
</script>
1216

    
1217
</body>
1218
</html>
(204-204/246)