Project

General

Profile

Download (24.4 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
##|+PRIV
31
##|*IDENT=page-system-certmanager
32
##|*NAME=System: Certificate Manager
33
##|*DESCR=Allow access to the 'System: Certificate Manager' page.
34
##|*MATCH=system_certmanager.php*
35
##|-PRIV
36

    
37
require("guiconfig.inc");
38
require_once("certs.inc");
39

    
40
$cert_methods = array(
41
	"existing" => "Import an existing Certificate",
42
	"internal" => "Create an internal Certificate",
43
	"external" => "Create a Certificate Signing Request");
44

    
45
$cert_keylens = array( "512", "1024", "2048", "4096");
46

    
47
$pgtitle = array("System", "Certificate Manager");
48

    
49
$id = $_GET['id'];
50
if (isset($_POST['id']))
51
	$id = $_POST['id'];
52

    
53
if (!is_array($config['system']['ca']))
54
	$config['system']['ca'] = array();
55

    
56
$a_ca =& $config['system']['ca'];
57

    
58
if (!is_array($config['system']['cert']))
59
	$config['system']['cert'] = array();
60

    
61
$a_cert =& $config['system']['cert'];
62

    
63
$internal_ca_count = 0;
64
foreach ($a_ca as $ca)
65
	if ($ca['prv'])	
66
		$internal_ca_count++;
67

    
68
$act = $_GET['act'];
69
if ($_POST['act'])
70
	$act = $_POST['act'];
71

    
72
if ($act == "del") {
73

    
74
	if (!$a_cert[$id]) {
75
		pfSenseHeader("system_certmanager.php");
76
		exit;
77
	}
78

    
79
	$name = $a_cert[$id]['name'];
80
	unset($a_cert[$id]);
81
	write_config();
82
	$savemsg = gettext("Certificate")." {$name} ".
83
				gettext("successfully deleted")."<br/>";
84
}
85

    
86
if ($act == "new") {
87
	$pconfig['method'] = $_GET['method'];
88
	$pconfig['keylen'] = "2048";
89
	$pconfig['lifetime'] = "365";
90
}
91

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

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

    
99
	$exp_name = urlencode("{$a_cert[$id]['name']}.crt");
100
	$exp_data = base64_decode($a_cert[$id]['crt']);
101
	$exp_size = strlen($exp_data);
102

    
103
	header("Content-Type: application/octet-stream");
104
	header("Content-Disposition: attachment; filename={$exp_name}");
105
	header("Content-Length: $exp_size");
106
	echo $exp_data;
107
	exit;
108
}
109

    
110
if ($act == "key") {
111

    
112
	if (!$a_cert[$id]) {
113
		pfSenseHeader("system_certmanager.php");
114
		exit;
115
	}
116

    
117
	$exp_name = urlencode("{$a_cert[$id]['name']}.key");
118
	$exp_data = base64_decode($a_cert[$id]['prv']);
119
	$exp_size = strlen($exp_data);
120

    
121
	header("Content-Type: application/octet-stream");
122
	header("Content-Disposition: attachment; filename={$exp_name}");
123
	header("Content-Length: $exp_size");
124
	echo $exp_data;
125
	exit;
126
}
127

    
128
if ($act == "csr") {
129

    
130
	if (!$a_cert[$id]) {
131
		pfSenseHeader("system_certmanager.php");
132
		exit;
133
	}
134

    
135
	$pconfig['name'] = $a_cert[$id]['name'];
136
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
137
}
138

    
139
if ($_POST) {
140

    
141
	if ($_POST['save'] == "Save") {
142

    
143
		unset($input_errors);
144
		$pconfig = $_POST;
145

    
146
		/* input validation */
147
		if ($pconfig['method'] == "existing") {
148
			$reqdfields = explode(" ",
149
					"name cert key");
150
			$reqdfieldsn = explode(",",
151
					"Desriptive name,Certificate data,Key data");
152
		}
153

    
154
		if ($pconfig['method'] == "internal") {
155
			$reqdfields = explode(" ",
156
					"name caref keylen lifetime dn_country dn_state dn_city ".
157
					"dn_organization dn_email dn_commonname");
158
			$reqdfieldsn = explode(",",
159
					"Desriptive name,Certificate authority,Key length,Lifetime,".
160
					"Distinguished name Country Code,".
161
					"Distinguished name State or Province,".
162
					"Distinguished name City,".
163
					"Distinguished name Organization,".
164
					"Distinguished name Email Address,".
165
					"Distinguished name Common Name");
166
		}
167

    
168
		if ($pconfig['method'] == "external") {
169
			$reqdfields = explode(" ",
170
					"name csr_keylen csr_dn_country csr_dn_state csr_dn_city ".
171
					"csr_dn_organization csr_dn_email csr_dn_commonname");
172
			$reqdfieldsn = explode(",",
173
					"Desriptive name,Key length,".
174
					"Distinguished name Country Code,".
175
					"Distinguished name State or Province,".
176
					"Distinguished name City,".
177
					"Distinguished name Organization,".
178
					"Distinguished name Email Address,".
179
					"Distinguished name Common Name");
180
		}
181

    
182
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
183

    
184
		/* if this is an AJAX caller then handle via JSON */
185
		if (isAjax() && is_array($input_errors)) {
186
			input_errors2Ajax($input_errors);
187
			exit;
188
		}
189

    
190
		/* save modifications */
191
		if (!$input_errors) {
192

    
193
			$cert = array();
194
			$cert['refid'] = uniqid();
195
			if (isset($id) && $a_cert[$id])
196
				$cert = $a_cert[$id];
197

    
198
		    $cert['name'] = $pconfig['name'];
199

    
200
			if ($pconfig['method'] == "existing")
201
				cert_import($cert, $pconfig['cert'], $pconfig['key']);
202

    
203
			if ($pconfig['method'] == "internal") {
204
				$dn = array(
205
					'countryName' => $pconfig['dn_country'],
206
					'stateOrProvinceName' => $pconfig['dn_state'],
207
					'localityName' => $pconfig['dn_city'],
208
					'organizationName' => $pconfig['dn_organization'],
209
					'emailAddress' => $pconfig['dn_email'],
210
					'commonName' => $pconfig['dn_commonname']);
211

    
212
				cert_create($cert, $pconfig['caref'], $pconfig['keylen'],
213
					$pconfig['lifetime'], $dn);
214
			}
215

    
216
			if ($pconfig['method'] == "external") {
217
				$dn = array(
218
					'countryName' => $pconfig['csr_dn_country'],
219
					'stateOrProvinceName' => $pconfig['csr_dn_state'],
220
					'localityName' => $pconfig['csr_dn_city'],
221
					'organizationName' => $pconfig['csr_dn_organization'],
222
					'emailAddress' => $pconfig['csr_dn_email'],
223
					'commonName' => $pconfig['csr_dn_commonname']);
224

    
225
				csr_generate($cert, $pconfig['csr_keylen'], $dn);
226
			}
227

    
228
			if (isset($id) && $a_cert[$id])
229
				$a_cert[$id] = $cert;
230
			else
231
				$a_cert[] = $cert;
232

    
233
			write_config();
234

    
235
//			pfSenseHeader("system_certmanager.php");
236
		}
237
	}
238

    
239
	if ($_POST['save'] == "Update") {
240
		unset($input_errors);
241
		$pconfig = $_POST;
242

    
243
		/* input validation */
244
		$reqdfields = explode(" ", "name cert");
245
		$reqdfieldsn = explode(",", "Desriptive name,Final Certificate data");
246

    
247
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
248

    
249
		/* make sure this csr and certificate subjects match */
250
		$subj_csr = csr_get_subject($pconfig['csr'], false);
251
		$subj_cert = cert_get_subject($pconfig['cert'], false);
252

    
253
		if (strcmp($subj_csr,$subj_cert))
254
			$input_errors[] = gettext("The certificate subject '{$subj_cert}' does not match the signing request subject.");
255

    
256
		/* if this is an AJAX caller then handle via JSON */
257
		if (isAjax() && is_array($input_errors)) {
258
			input_errors2Ajax($input_errors);
259
			exit;
260
		}
261

    
262
		/* save modifications */
263
		if (!$input_errors) {
264

    
265
			$cert = $a_cert[$id];
266

    
267
			$cert['name'] = $pconfig['name'];
268

    
269
			csr_complete($cert, $pconfig['cert']);
270

    
271
			$a_cert[$id] = $cert;
272

    
273
			write_config();
274

    
275
			pfSenseHeader("system_certmanager.php");
276
		}
277
	}
278
}
279

    
280
include("head.inc");
281
?>
282

    
283
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
284
<?php include("fbegin.inc"); ?>
285
<script type="text/javascript">
286
<!--
287

    
288
function method_change() {
289

    
290
<?php
291
	if ($internal_ca_count)
292
		$submit_style = "";
293
	else
294
		$submit_style = "none";
295
?>
296

    
297
	method = document.iform.method.selectedIndex;
298

    
299
	switch (method) {
300
		case 0:
301
			document.getElementById("existing").style.display="";
302
			document.getElementById("internal").style.display="none";
303
			document.getElementById("external").style.display="none";
304
			document.getElementById("submit").style.display="";
305
			break;
306
		case 1:
307
			document.getElementById("existing").style.display="none";
308
			document.getElementById("internal").style.display="";
309
			document.getElementById("external").style.display="none";
310
			document.getElementById("submit").style.display="<?=$submit_style;?>";
311
			break;
312
		case 2:
313
			document.getElementById("existing").style.display="none";
314
			document.getElementById("internal").style.display="none";
315
			document.getElementById("external").style.display="";
316
			document.getElementById("submit").style.display="";
317
			break;
318
	}
319
}
320

    
321
<?php if ($internal_ca_count): ?>
322
function internalca_change() {
323

    
324
	index = document.iform.caref.selectedIndex;
325
	caref = document.iform.caref[index].value;
326

    
327
	switch (caref) {
328
<?php
329
		foreach ($a_ca as $ca):
330
			if (!$ca['prv'])
331
				continue;
332
			$subject = cert_get_subject_array($ca['crt']);
333
?>
334
		case "<?=$ca['refid'];?>":
335
			document.iform.dn_country.value = "<?=$subject[0]['v'];?>";
336
			document.iform.dn_state.value = "<?=$subject[1]['v'];?>";
337
			document.iform.dn_city.value = "<?=$subject[2]['v'];?>";
338
			document.iform.dn_organization.value = "<?=$subject[3]['v'];?>";
339
			break;
340
<?php	endforeach; ?>
341
	}
342
}
343
<?php endif; ?>
344

    
345
//-->
346
</script>
347
<?php
348
	if ($input_errors)
349
		print_input_errors($input_errors);
350
	if ($savemsg)
351
		print_info_box($savemsg);
352
?>
353
<table width="100%" border="0" cellpadding="0" cellspacing="0">
354
	<tr>
355
		<td class="tabnavtbl">
356
		<?php
357
			$tab_array = array();
358
			$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
359
			$tab_array[] = array(gettext("Certificates"), true, "system_certmanager.php");
360
			display_top_tabs($tab_array);
361
		?>
362
		</td>
363
	</tr>
364
	<tr>
365
		<td id="mainarea">
366
			<div class="tabcont">
367

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

    
370
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
371
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
372
						<tr>
373
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
374
							<td width="78%" class="vtable">
375
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
376
							</td>
377
						</tr>
378
						<?php if (!isset($id)): ?>
379
						<tr>
380
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
381
							<td width="78%" class="vtable">
382
								<select name='method' id='method' class="formselect" onchange='method_change()'>
383
								<?php
384
									foreach($cert_methods as $method => $desc):
385
									$selected = "";
386
									if ($pconfig['method'] == $method)
387
										$selected = "selected";
388
								?>
389
									<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option>
390
								<?php endforeach; ?>
391
								</select>
392
							</td>
393
						</tr>
394
						<?php endif; ?>
395
					</table>
396

    
397
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing">
398
						<tr>
399
							<td colspan="2" class="list" height="12"></td>
400
						</tr>
401
						<tr>
402
							<td colspan="2" valign="top" class="listtopic">Existing Certificate</td>
403
						</tr>
404

    
405
						<tr>
406
							<td width="22%" valign="top" class="vncellreq">Certificate data</td>
407
							<td width="78%" class="vtable">
408
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=$pconfig['cert'];?></textarea>
409
								<br>
410
								Paste a certificate in X.509 PEM format here.</td>
411
							</td>
412
						</tr>
413
						<tr>
414
							<td width="22%" valign="top" class="vncellreq">Private key data</td>
415
							<td width="78%" class="vtable">
416
								<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=$pconfig['key'];?></textarea>
417
								<br>
418
								Paste a private key in X.509 PEM format here.</td>
419
							</td>
420
						</tr>
421
					</table>
422

    
423
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal">
424
						<tr>
425
							<td colspan="2" class="list" height="12"></td>
426
						</tr>
427
						<tr>
428
							<td colspan="2" valign="top" class="listtopic">Internal Certificate</td>
429
						</tr>
430

    
431
						<?php if (!$internal_ca_count): ?>
432

    
433
						<tr>
434
							<td colspan="2" align="center" class="vtable">
435
								No internal Certificate Authorities have been defined. You must
436
								<a href="system_camanager.php?act=new&method=internal">create</a>
437
								an internal CA before creating an internal certificate.
438
							</td>
439
						</tr>
440

    
441
						<?php else: ?>
442

    
443
						<tr>
444
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
445
							<td width="78%" class="vtable">
446
								<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
447
								<?php
448
									foreach( $a_ca as $ca):
449
									if (!$ca['prv'])
450
										continue;
451
									$selected = "";
452
									if ($pconfig['caref'] == $ca['refid'])
453
										$selected = "selected";
454
								?>
455
									<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['name'];?></option>
456
								<?php endforeach; ?>
457
								</select>
458
							</td>
459
						</tr>
460
						<tr>
461
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
462
							<td width="78%" class="vtable">
463
								<select name='keylen' class="formselect">
464
								<?php
465
									foreach( $cert_keylens as $len):
466
									$selected = "";
467
									if ($pconfig['keylen'] == $len)
468
										$selected = "selected";
469
								?>
470
									<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
471
								<?php endforeach; ?>
472
								</select>
473
								bits
474
							</td>
475
						</tr>
476
						<tr>
477
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
478
							<td width="78%" class="vtable">
479
								<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
480
								days
481
							</td>
482
						</tr>
483
						<tr>
484
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
485
							<td width="78%" class="vtable">
486
								<table border="0" cellspacing="0" cellpadding="2">
487
									<tr>
488
										<td align="right">Country Code : &nbsp;</td>
489
										<td align="left">
490
											<input name="dn_country" type="text" class="formfld unknown" maxlength="2" size="2" value="<?=htmlspecialchars($pconfig['dn_country']);?>" readonly/>
491
										</td>
492
									</tr>
493
									<tr>
494
										<td align="right">State or Province : &nbsp;</td>
495
										<td align="left">
496
											<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>" readonly/>
497
										</td>
498
									</tr>
499
									<tr>
500
										<td align="right">City : &nbsp;</td>
501
										<td align="left">
502
											<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>" readonly/>
503
										</td>
504
									</tr>
505
									<tr>
506
										<td align="right">Organization : &nbsp;</td>
507
										<td align="left">
508
											<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>" readonly/>
509
										</td>
510
									</tr>
511
									<tr>
512
										<td align="right">Email Address : &nbsp;</td>
513
										<td align="left">
514
											<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/>
515
											&nbsp;
516
											<em>ex:</em>
517
											&nbsp;
518
											webadmin@mycompany.com
519
										</td>
520
									</tr>
521
									<tr>
522
										<td align="right">Common Name : &nbsp;</td>
523
										<td align="left">
524
											<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/>
525
											&nbsp;
526
											<em>ex:</em>
527
											&nbsp;
528
											www.pfsense.org
529
										</td>
530
									</tr>
531
								</table>
532
							</td>
533
						</tr>
534

    
535
					<?php endif; ?>
536

    
537
					</table>
538

    
539
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="external">
540
						<tr>
541
							<td colspan="2" class="list" height="12"></td>
542
						</tr>
543
						<tr>
544
							<td colspan="2" valign="top" class="listtopic">External Signing Request</td>
545
						</tr>
546
						<tr>
547
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
548
							<td width="78%" class="vtable">
549
								<select name='csr_keylen' class="formselect">
550
								<?php
551
									foreach( $cert_keylens as $len):
552
									$selected = "";
553
									if ($pconfig['keylen'] == $len)
554
										$selected = "selected";
555
								?>
556
									<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
557
								<?php endforeach; ?>
558
								</select>
559
								bits
560
							</td>
561
						</tr>
562
						<tr>
563
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
564
							<td width="78%" class="vtable">
565
								<table border="0" cellspacing="0" cellpadding="2">
566
									<tr>
567
										<td align="right">Country Code : &nbsp;</td>
568
										<td align="left">
569
											<input name="csr_dn_country" type="text" class="formfld unknown" size="2" value="<?=htmlspecialchars($pconfig['csr_dn_country']);?>" />
570
											&nbsp;
571
											<em>ex:</em>
572
											&nbsp;
573
											US
574
											&nbsp;
575
											<em>( two letters )</em>
576
										</td>
577
									</tr>
578
									<tr>
579
										<td align="right">State or Province : &nbsp;</td>
580
										<td align="left">
581
											<input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_state']);?>" />
582
											&nbsp;
583
											<em>ex:</em>
584
											&nbsp;
585
											Texas
586
										</td>
587
									</tr>
588
									<tr>
589
										<td align="right">City : &nbsp;</td>
590
										<td align="left">
591
											<input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_city']);?>" />
592
											&nbsp;
593
											<em>ex:</em>
594
											&nbsp;
595
											Austin
596
										</td>
597
									</tr>
598
									<tr>
599
										<td align="right">Organization : &nbsp;</td>
600
										<td align="left">
601
											<input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_organization']);?>" />
602
											&nbsp;
603
											<em>ex:</em>
604
											&nbsp;
605
											My Company Inc.
606
										</td>
607
									</tr>
608
									<tr>
609
										<td align="right">Email Address : &nbsp;</td>
610
										<td align="left">
611
											<input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_email']);?>"/>
612
											&nbsp;
613
											<em>ex:</em>
614
											&nbsp;
615
											webadmin@mycompany.com
616
										</td>
617
									</tr>
618
									<tr>
619
										<td align="right">Common Name : &nbsp;</td>
620
										<td align="left">
621
											<input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_commonname']);?>"/>
622
											&nbsp;
623
											<em>ex:</em>
624
											&nbsp;
625
											www.pfsense.org
626
										</td>
627
									</tr>
628
								</table>
629
							</td>
630
						</tr>
631
					</table>
632

    
633
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
634
						<tr>
635
							<td width="22%" valign="top">&nbsp;</td>
636
							<td width="78%">
637
								<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
638
								<?php if (isset($id) && $a_cert[$id]): ?>
639
								<input name="id" type="hidden" value="<?=$id;?>" />
640
								<?php endif;?>
641
							</td>
642
						</tr>
643
					</table>
644
				</form>
645

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

    
648
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
649
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
650
						<tr>
651
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
652
							<td width="78%" class="vtable">
653
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
654
							</td>
655
						</tr>
656
						<tr>
657
							<td colspan="2" class="list" height="12"></td>
658
						</tr>
659
						<tr>
660
							<td colspan="2" valign="top" class="listtopic">Complete Signing Request</td>
661
						</tr>
662

    
663
						<tr>
664
							<td width="22%" valign="top" class="vncellreq">Signing Request data</td>
665
							<td width="78%" class="vtable">
666
								<textarea name="csr" id="csr" cols="65" rows="7" class="formfld_cert" readonly><?=$pconfig['csr'];?></textarea>
667
								<br>
668
								Copy the certificate signing data from here and forward it to your certificate authority for singing.</td>
669
							</td>
670
						</tr>
671
						<tr>
672
							<td width="22%" valign="top" class="vncellreq">Final Certificate data</td>
673
							<td width="78%" class="vtable">
674
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=$pconfig['cert'];?></textarea>
675
								<br>
676
								Paste the certificate received from your cerificate authority here.</td>
677
							</td>
678
						</tr>
679
						<tr>
680
							<td width="22%" valign="top">&nbsp;</td>
681
							<td width="78%">
682
								<input id="submit" name="save" type="submit" class="formbtn" value="Update" />
683
								<?php if (isset($id) && $a_cert[$id]): ?>
684
								<input name="id" type="hidden" value="<?=$id;?>" />
685
								<input name="act" type="hidden" value="csr" />
686
								<?php endif;?>
687
							</td>
688
						</tr>
689
					</table>
690
				</form>
691

    
692
				<?php else:?>
693

    
694
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
695
					<tr>
696
						<td width="20%" class="listhdrr">Name</td>
697
						<td width="20%" class="listhdrr">CA</td>
698
						<td width="40%" class="listhdrr">Distinguished Name</td>
699
						<td width="10%" class="list"></td>
700
					</tr>
701
					<?php
702
						$i = 0;
703
						foreach($a_cert as $cert):
704
							$name = htmlspecialchars($cert['name']);
705

    
706
							if ($cert['crt']) {
707
								$subj = htmlspecialchars(cert_get_subject($cert['crt']));
708
								$caname = "<em>external</em>";
709
							}
710

    
711
							if ($cert['csr']) {
712
								$subj = htmlspecialchars(csr_get_subject($cert['csr']));
713
								$caname = "<em>external - signature pending</em>";
714
							}
715

    
716
							$ca = lookup_ca($cert['caref']);
717
							if ($ca)
718
								$caname = $ca['name'];
719

    
720
							if($cert['prv'])
721
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
722
							else
723
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
724
					?>
725
					<tr>
726
						<td class="listlr">
727
							<table border="0" cellpadding="0" cellspacing="0">
728
								<tr>
729
									<td align="left" valign="center">
730
										<img src="<?=$certimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
731
									</td>
732
									<td align="left" valign="middle">
733
										<?=$name;?>
734
									</td>
735
								</tr>
736
							</table>
737
						</td>
738
						<td class="listr"><?=$caname;?>&nbsp;</td>
739
						<td class="listr"><?=$subj;?>&nbsp;</td>
740
						<td valign="middle" nowrap class="list">
741
							<a href="system_certmanager.php?act=exp&id=<?=$i;?>")">
742
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export cert" alt="export ca" width="17" height="17" border="0" />
743
							</a>
744
							<a href="system_certmanager.php?act=key&id=<?=$i;?>")">
745
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export key" alt="export ca" width="17" height="17" border="0" />
746
							</a>
747
							<a href="system_certmanager.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate?");?>')">
748
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete cert" alt="delete cert" width="17" height="17" border="0" />
749
							</a>
750
							<?php	if ($cert['csr']): ?>
751
							&nbsp;
752
								<a href="system_certmanager.php?act=csr&id=<?=$i;?>">
753
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="update csr" alt="update csr" width="17" height="17" border="0" />
754
							</a>
755
							<?php	endif; ?>
756
						</td>
757
					</tr>
758
					<?php
759
							$i++;
760
						endforeach;
761
					?>
762
					<tr>
763
						<td class="list" colspan="3"></td>
764
						<td class="list">
765
							<a href="system_certmanager.php?act=new">
766
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add or import ca" alt="add ca" width="17" height="17" border="0" />
767
							</a>
768
						</td>
769
					</tr>
770
				</table>
771

    
772
				<?php endif; ?>
773

    
774
			</div>
775
		</td>
776
	</tr>
777
</table>
778
<?php include("fend.inc");?>
779
<script type="text/javascript">
780
<!--
781

    
782
method_change();
783
internalca_change();
784

    
785
//-->
786
</script>
787

    
788
</body>
(176-176/216)