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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
138
if ($_POST) {
139

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
232
			write_config();
233

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

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

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

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

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

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

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

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

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

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

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

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

    
272
			write_config();
273

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

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

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

    
287
function method_change() {
288

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    
440
						<?php else: ?>
441

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

    
534
					<?php endif; ?>
535

    
536
					</table>
537

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

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

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

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

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

    
691
				<?php else:?>
692

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

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

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

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

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

    
771
				<?php endif; ?>
772

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

    
781
method_change();
782
internalca_change();
783

    
784
//-->
785
</script>
786

    
787
</body>
(163-163/203)