Project

General

Profile

Download (41.3 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
global $openssl_digest_algs;
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['type'] = "user";
111
	$pconfig['lifetime'] = "3650";
112
}
113

    
114
if ($act == "exp") {
115

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

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

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

    
132
if ($act == "key") {
133

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

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

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

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

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

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

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

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

    
172
if ($act == "csr") {
173

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

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

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

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

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

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

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

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

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

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

    
302
		/* if this is an AJAX caller then handle via JSON */
303
		if (isAjax() && is_array($input_errors)) {
304
			input_errors2Ajax($input_errors);
305
			exit;
306
		}
307

    
308
		/* save modifications */
309
		if (!$input_errors) {
310

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

    
321
				$cert['descr'] = $pconfig['descr'];
322

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

    
325
				if ($pconfig['method'] == "import")
326
					cert_import($cert, $pconfig['cert'], $pconfig['key']);
327

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

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

    
376
				if (isset($id) && $a_cert[$id])
377
					$a_cert[$id] = $cert;
378
				else
379
					$a_cert[] = $cert;
380
				if (isset($a_user) && isset($userid))
381
					$a_user[$userid]['cert'][] = $cert['refid'];
382
			}
383

    
384
			if (!$input_errors)
385
				write_config();
386

    
387
			if ($userid)
388
				pfSenseHeader("system_usermanager.php?act=edit&id={$userid}");
389
		}
390
	}
391

    
392
	if ($_POST['save'] == gettext("Update")) {
393
		unset($input_errors);
394
		$pconfig = $_POST;
395

    
396
		/* input validation */
397
		$reqdfields = explode(" ", "descr cert");
398
		$reqdfieldsn = array(
399
			gettext("Descriptive name"),
400
			gettext("Final Certificate data"));
401

    
402
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
403

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

    
424
		/* if this is an AJAX caller then handle via JSON */
425
		if (isAjax() && is_array($input_errors)) {
426
			input_errors2Ajax($input_errors);
427
			exit;
428
		}
429

    
430
		/* save modifications */
431
		if (!$input_errors) {
432

    
433
			$cert = $a_cert[$id];
434

    
435
			$cert['descr'] = $pconfig['descr'];
436

    
437
			csr_complete($cert, $pconfig['cert']);
438

    
439
			$a_cert[$id] = $cert;
440

    
441
			write_config();
442

    
443
			pfSenseHeader("system_certmanager.php");
444
		}
445
	}
446
}
447

    
448
include("head.inc");
449
?>
450

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

    
456
function method_change() {
457

    
458
<?php
459
	if ($internal_ca_count)
460
		$submit_style = "";
461
	else
462
		$submit_style = "none";
463
?>
464

    
465
	method = document.iform.method.selectedIndex;
466

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

    
503
<?php if ($internal_ca_count): ?>
504
function internalca_change() {
505

    
506
	index = document.iform.caref.selectedIndex;
507
	caref = document.iform.caref[index].value;
508

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

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

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

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

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

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

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

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

    
640
						<?php if (!$internal_ca_count): ?>
641

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

    
650
						<?php else: ?>
651

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

    
829
					<?php endif; ?>
830

    
831
					</table>
832

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

    
931
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing">
932
						<tr>
933
							<td colspan="2" class="list" height="12"></td>
934
						</tr>
935
						<tr>
936
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Choose an Existing Certificate");?></td>
937
						</tr>
938
						<tr>
939
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Existing Certificates");?></td>
940
							<td width="78%" class="vtable">
941
								<?php if (isset($userid) && $a_user): ?>
942
								<input name="userid" type="hidden" value="<?=$userid;?>" />
943
								<?php endif;?>
944
								<select name='certref' class="formselect">
945
								<?php
946
									foreach ($config['cert'] as $cert):
947
										$selected = "";
948
										$caname = "";
949
										$inuse = "";
950
										$revoked = "";
951
										if (in_array($cert['refid'], $config['system']['user'][$userid]['cert']))
952
											continue;
953
										$ca = lookup_ca($cert['caref']);
954
										if ($ca)
955
											$caname = " (CA: {$ca['descr']})";
956
										if ($pconfig['certref'] == $cert['refid'])
957
											$selected = "selected";
958
										if (cert_in_use($cert['refid']))
959
											$inuse = " *In Use";
960
											if (is_cert_revoked($cert))
961
											$revoked = " *Revoked";
962
								?>
963
									<option value="<?=$cert['refid'];?>" <?=$selected;?>><?=$cert['descr'] . $caname . $inuse . $revoked;?></option>
964
								<?php endforeach; ?>
965
								</select>
966
							</td>
967
						</tr>
968
					</table>
969

    
970
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
971
						<tr>
972
							<td width="22%" valign="top">&nbsp;</td>
973
							<td width="78%">
974
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save");?>" />
975
								<?php if (isset($id) && $a_cert[$id]): ?>
976
								<input name="id" type="hidden" value="<?=$id;?>" />
977
								<?php endif;?>
978
							</td>
979
						</tr>
980
					</table>
981
				</form>
982

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

    
985
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
986
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
987
						<tr>
988
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
989
							<td width="78%" class="vtable">
990
								<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/>
991
							</td>
992
						</tr>
993
						<tr>
994
							<td colspan="2" class="list" height="12"></td>
995
						</tr>
996
						<tr>
997
							<td colspan="2" valign="top" class="listtopic"><?=gettext("Complete Signing Request");?></td>
998
						</tr>
999

    
1000
						<tr>
1001
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Signing Request data");?></td>
1002
							<td width="78%" class="vtable">
1003
								<textarea name="csr" id="csr" cols="65" rows="7" class="formfld_cert" readonly><?=htmlspecialchars($pconfig['csr']);?></textarea>
1004
								<br>
1005
								<?=gettext("Copy the certificate signing data from here and forward it to your certificate authority for signing.");?></td>
1006
							</td>
1007
						</tr>
1008
						<tr>
1009
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Final Certificate data");?></td>
1010
							<td width="78%" class="vtable">
1011
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea>
1012
								<br>
1013
								<?=gettext("Paste the certificate received from your certificate authority here.");?></td>
1014
							</td>
1015
						</tr>
1016
						<tr>
1017
							<td width="22%" valign="top">&nbsp;</td>
1018
							<td width="78%">
1019
								<?php /* if ( isset($subject_mismatch) && $subject_mismatch === true): ?>
1020
								<input id="ignoresubjectmismatch" name="ignoresubjectmismatch" type="checkbox" class="formbtn" value="yes" />
1021
								<label for="ignoresubjectmismatch"><strong><?=gettext("Ignore certificate subject mismatch"); ?></strong></label><br />
1022
								<?php echo gettext("Warning: Using this option may create an " .
1023
								"invalid certificate.  Check this box to disable the request -> " .
1024
								"response subject verification. ");
1025
								?><br/>
1026
								<?php endif; */ ?>
1027
								<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Update");?>" />
1028
								<?php if (isset($id) && $a_cert[$id]): ?>
1029
								<input name="id" type="hidden" value="<?=$id;?>" />
1030
								<input name="act" type="hidden" value="csr" />
1031
								<?php endif;?>
1032
							</td>
1033
						</tr>
1034
					</table>
1035
				</form>
1036

    
1037
				<?php else:?>
1038

    
1039
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
1040
					<tr>
1041
						<td width="15%" class="listhdrr"><?=gettext("Name");?></td>
1042
						<td width="15%" class="listhdrr"><?=gettext("Issuer");?></td>
1043
						<td width="40%" class="listhdrr"><?=gettext("Distinguished Name");?></td>
1044
						<td width="10%" class="listhdrr"><?=gettext("In Use");?></td>
1045
						<td width="10%" class="list"></td>
1046
					</tr>
1047
					<?php
1048
						$i = 0;
1049
						foreach($a_cert as $cert):
1050
							$name = htmlspecialchars($cert['descr']);
1051
							
1052
							if ($cert['crt']) {
1053
								$subj = cert_get_subject($cert['crt']);
1054
								$issuer = cert_get_issuer($cert['crt']);
1055
								$purpose = cert_get_purpose($cert['crt']);
1056
								if($subj==$issuer)
1057
								  $caname = "<em>" . gettext("self-signed") . "</em>";
1058
								else
1059
							    $caname = "<em>" . gettext("external"). "</em>";
1060
							  $subj = htmlspecialchars($subj);
1061
							}
1062

    
1063
							if ($cert['csr']) {
1064
								$subj = htmlspecialchars(csr_get_subject($cert['csr']));
1065
								$caname = "<em>" . gettext("external - signature pending") . "</em>";
1066
							}
1067

    
1068
							$ca = lookup_ca($cert['caref']);
1069
							if ($ca)
1070
								$caname = $ca['descr'];
1071

    
1072
							if($cert['prv'])
1073
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
1074
							else
1075
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
1076
					?>
1077
					<tr>
1078
						<td class="listlr">
1079
							<table border="0" cellpadding="0" cellspacing="0">
1080
								<tr>
1081
									<td align="left" valign="center">
1082
										<img src="<?=$certimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
1083
									</td>
1084
									<td align="left" valign="middle">
1085
										<?=$name;?>
1086
									</td>
1087
								</tr>
1088
								<tr><td>&nbsp;</td></tr>
1089
								<?php if ($cert['type']): ?>
1090
								<tr><td colspan="2"><em><?php echo $cert_types[$cert['type']]; ?></em></td></tr>
1091
								<?php endif; ?>
1092
								<?php if (is_array($purpose)): ?>
1093
								<tr><td colspan="2">
1094
									CA: <?php echo $purpose['ca']; ?>,
1095
									Server: <?php echo $purpose['server']; ?>
1096
								</td></tr>
1097
								<?php endif; ?>
1098
							</table>
1099
						</td>
1100
						<td class="listr"><?=$caname;?>&nbsp;</td>
1101
						<td class="listr"><?=$subj;?>&nbsp;</td>
1102
						<td class="listr">
1103
							<?php if (is_cert_revoked($cert)): ?>
1104
							<b>Revoked</b><br/>
1105
							<?php endif; ?>
1106
							<?php if (is_webgui_cert($cert['refid'])): ?>
1107
							webConfigurator<br/>
1108
							<?php endif; ?>
1109
							<?php if (is_user_cert($cert['refid'])): ?>
1110
							User Cert<br/>
1111
							<?php endif; ?>
1112
							<?php if (is_openvpn_server_cert($cert['refid'])): ?>
1113
							OpenVPN Server<br/>
1114
							<?php endif; ?>
1115
							<?php if (is_openvpn_client_cert($cert['refid'])): ?>
1116
							OpenVPN Client<br/>
1117
							<?php endif; ?>
1118
							<?php if (is_ipsec_cert($cert['refid'])): ?>
1119
							IPsec Tunnel<br/>
1120
							<?php endif; ?>
1121
							<?php if (is_captiveportal_cert($cert['refid'])): ?>
1122
							Captive Portal<br/>
1123
							<?php endif; ?>
1124
						</td>
1125
						<td valign="middle" nowrap class="list">
1126
							<a href="system_certmanager.php?act=exp&id=<?=$i;?>">
1127
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export cert");?>" alt="<?=gettext("export ca");?>" width="17" height="17" border="0" />
1128
							</a>
1129
							<a href="system_certmanager.php?act=key&id=<?=$i;?>">
1130
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export key");?>" alt="<?=gettext("export ca");?>" width="17" height="17" border="0" />
1131
							</a>
1132
							<a href="system_certmanager.php?act=p12&id=<?=$i;?>">
1133
								<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" />
1134
							</a>
1135
							<?php	if (!cert_in_use($cert['refid'])): ?>
1136
							<a href="system_certmanager.php?act=del&id=<?=$i;?>" onClick="return confirm('<?=gettext("Do you really want to delete this Certificate?");?>')">
1137
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete cert");?>" alt="<?=gettext("delete cert");?>" width="17" height="17" border="0" />
1138
							</a>
1139
							<?php	endif; ?>
1140
							<?php	if ($cert['csr']): ?>
1141
							&nbsp;
1142
								<a href="system_certmanager.php?act=csr&id=<?=$i;?>">
1143
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("update csr");?>" alt="<?=gettext("update csr");?>" width="17" height="17" border="0" />
1144
							</a>
1145
							<?php	endif; ?>
1146
						</td>
1147
					</tr>
1148
					<?php
1149
							$i++;
1150
						endforeach;
1151
					?>
1152
					<tr>
1153
						<td class="list" colspan="4"></td>
1154
						<td class="list">
1155
							<a href="system_certmanager.php?act=new">
1156
								<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" />
1157
							</a>
1158
						</td>
1159
					</tr>
1160
					<tr>
1161
						<td>&nbsp;</td>
1162
						<td colspan="3"><?=gettext("Note: You can only delete a certificate if it is not currently in use.");?></td>
1163
					</tr>
1164
				</table>
1165

    
1166
				<?php endif; ?>
1167

    
1168
			</div>
1169
		</td>
1170
	</tr>
1171
</table>
1172
<?php include("fend.inc");?>
1173
<script type="text/javascript">
1174
<!--
1175

    
1176
method_change();
1177
internalca_change();
1178

    
1179
//-->
1180
</script>
1181

    
1182
</body>
(207-207/249)