Project

General

Profile

Download (23.9 KB) Statistics
| Branch: | Tag: | Revision:
1 64cc39d3 Matthew Grooms
<?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 93823b10 Matthew Grooms
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 64cc39d3 Matthew Grooms
if ($act == "csr") {
110
111
	if (!$a_cert[$id]) {
112
		pfSenseHeader("system_certmanager.php");
113
		exit;
114
	}
115
116
	$pconfig['name'] = $a_cert[$id]['name'];
117
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
118
}
119
120
if ($_POST) {
121
122
	if ($_POST['save'] == "Save") {
123
124
		unset($input_errors);
125
		$pconfig = $_POST;
126
127
		/* input validation */
128
		if ($pconfig['method'] == "existing") {
129
			$reqdfields = explode(" ",
130
					"name cert key");
131
			$reqdfieldsn = explode(",",
132
					"Desriptive name,Certificate data,Key data");
133
		}
134
135
		if ($pconfig['method'] == "internal") {
136
			$reqdfields = explode(" ",
137
					"name caref keylen lifetime dn_country dn_state dn_city ".
138
					"dn_organization dn_email dn_commonname");
139
			$reqdfieldsn = explode(",",
140
					"Desriptive name,Certificate authority,Key length,Lifetime,".
141
					"Distinguished name Country Code,".
142
					"Distinguished name State or Province,".
143
					"Distinguished name City,".
144
					"Distinguished name Organization,".
145
					"Distinguished name Email Address,".
146
					"Distinguished name Common Name");
147
		}
148
149
		if ($pconfig['method'] == "external") {
150
			$reqdfields = explode(" ",
151
					"name csr_keylen csr_dn_country csr_dn_state csr_dn_city ".
152
					"csr_dn_organization csr_dn_email csr_dn_commonname");
153
			$reqdfieldsn = explode(",",
154
					"Desriptive name,Key length,".
155
					"Distinguished name Country Code,".
156
					"Distinguished name State or Province,".
157
					"Distinguished name City,".
158
					"Distinguished name Organization,".
159
					"Distinguished name Email Address,".
160
					"Distinguished name Common Name");
161
		}
162
163
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
164
165
		/* if this is an AJAX caller then handle via JSON */
166
		if (isAjax() && is_array($input_errors)) {
167
			input_errors2Ajax($input_errors);
168
			exit;
169
		}
170
171
		/* save modifications */
172
		if (!$input_errors) {
173
174
			$cert = array();
175
			$cert['refid'] = uniqid();
176
			if (isset($id) && $a_cert[$id])
177
				$cert = $a_cert[$id];
178
179
		    $cert['name'] = $pconfig['name'];
180
181
			if ($pconfig['method'] == "existing")
182
				cert_import($cert, $pconfig['cert'], $pconfig['key']);
183
184
			if ($pconfig['method'] == "internal") {
185
				$dn = array(
186
					'countryName' => $pconfig['dn_country'],
187
					'stateOrProvinceName' => $pconfig['dn_state'],
188
					'localityName' => $pconfig['dn_city'],
189
					'organizationName' => $pconfig['dn_organization'],
190
					'emailAddress' => $pconfig['dn_email'],
191
					'commonName' => $pconfig['dn_commonname']);
192
193
				cert_create($cert, $pconfig['caref'], $pconfig['keylen'],
194
					$pconfig['lifetime'], $dn);
195
			}
196
197
			if ($pconfig['method'] == "external") {
198
				$dn = array(
199
					'countryName' => $pconfig['csr_dn_country'],
200
					'stateOrProvinceName' => $pconfig['csr_dn_state'],
201
					'localityName' => $pconfig['csr_dn_city'],
202
					'organizationName' => $pconfig['csr_dn_organization'],
203
					'emailAddress' => $pconfig['csr_dn_email'],
204
					'commonName' => $pconfig['csr_dn_commonname']);
205
206
				csr_generate($cert, $pconfig['csr_keylen'], $dn);
207
			}
208
209
			if (isset($id) && $a_cert[$id])
210
				$a_cert[$id] = $cert;
211
			else
212
				$a_cert[] = $cert;
213
214
			write_config();
215
216
//			pfSenseHeader("system_certmanager.php");
217
		}
218
	}
219
220
	if ($_POST['save'] == "Update") {
221
		unset($input_errors);
222
		$pconfig = $_POST;
223
224
		/* input validation */
225
		$reqdfields = explode(" ", "name cert");
226
		$reqdfieldsn = explode(",", "Desriptive name,Final Certificate data");
227
228
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
229
230
		/* make sure this csr and certificate subjects match */
231
		$subj_csr = csr_get_subject($pconfig['csr'], false);
232
		$subj_cert = cert_get_subject($pconfig['cert'], false);
233
234
		if (strcmp($subj_csr,$subj_cert))
235
			$input_errors[] = gettext("The certificate subject '{$subj_cert}' does not match the signing request subject.");
236
237
		/* if this is an AJAX caller then handle via JSON */
238
		if (isAjax() && is_array($input_errors)) {
239
			input_errors2Ajax($input_errors);
240
			exit;
241
		}
242
243
		/* save modifications */
244
		if (!$input_errors) {
245
246
			$cert = $a_cert[$id];
247
248
			$cert['name'] = $pconfig['name'];
249
250
			csr_complete($cert, $pconfig['cert']);
251
252
			$a_cert[$id] = $cert;
253
254
			write_config();
255
256
			pfSenseHeader("system_certmanager.php");
257
		}
258
	}
259
}
260
261
include("head.inc");
262
?>
263
264
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
265
<?php include("fbegin.inc"); ?>
266
<script type="text/javascript">
267
<!--
268
269
function method_change() {
270
271
<?php
272
	if ($internal_ca_count)
273
		$submit_style = "";
274
	else
275
		$submit_style = "none";
276
?>
277
278
	method = document.iform.method.selectedIndex;
279
280
	switch (method) {
281
		case 0:
282
			document.getElementById("existing").style.display="";
283
			document.getElementById("internal").style.display="none";
284
			document.getElementById("external").style.display="none";
285 96c7a492 Matthew Grooms
			document.getElementById("submit").style.display="";
286 64cc39d3 Matthew Grooms
			break;
287
		case 1:
288
			document.getElementById("existing").style.display="none";
289
			document.getElementById("internal").style.display="";
290
			document.getElementById("external").style.display="none";
291
			document.getElementById("submit").style.display="<?=$submit_style;?>";
292
			break;
293
		case 2:
294
			document.getElementById("existing").style.display="none";
295
			document.getElementById("internal").style.display="none";
296
			document.getElementById("external").style.display="";
297 96c7a492 Matthew Grooms
			document.getElementById("submit").style.display="";
298 64cc39d3 Matthew Grooms
			break;
299
	}
300
}
301
302
<?php if ($internal_ca_count): ?>
303
function internalca_change() {
304
305
	index = document.iform.caref.selectedIndex;
306
	caref = document.iform.caref[index].value;
307
308
	switch (caref) {
309
<?php
310
		foreach ($a_ca as $ca):
311
			if (!$ca['prv'])
312
				continue;
313
			$subject = cert_get_subject_array($ca['crt']);
314
?>
315
		case "<?=$ca['refid'];?>":
316
			document.iform.dn_country.value = "<?=$subject[0]['v'];?>";
317
			document.iform.dn_state.value = "<?=$subject[1]['v'];?>";
318
			document.iform.dn_city.value = "<?=$subject[2]['v'];?>";
319
			document.iform.dn_organization.value = "<?=$subject[3]['v'];?>";
320
			break;
321
<?php	endforeach; ?>
322
	}
323
}
324
<?php endif; ?>
325
326
//-->
327
</script>
328
<?php
329
	if ($input_errors)
330
		print_input_errors($input_errors);
331
	if ($savemsg)
332
		print_info_box($savemsg);
333
?>
334
<table width="100%" border="0" cellpadding="0" cellspacing="0">
335
	<tr>
336
		<td class="tabnavtbl">
337
		<?php
338
			$tab_array = array();
339
			$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
340
			$tab_array[] = array(gettext("Certificates"), true, "system_certmanager.php");
341
			display_top_tabs($tab_array);
342
		?>
343
		</td>
344
	</tr>
345
	<tr>
346 96c7a492 Matthew Grooms
		<td id="mainarea">
347
			<div class="tabcont">
348
349
				<?php if ($act == "new" || (($_POST['save'] == "Save") && $input_errors)): ?>
350
351
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
352
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
353
						<tr>
354
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
355
							<td width="78%" class="vtable">
356
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
357
							</td>
358
						</tr>
359
						<?php if (!isset($id)): ?>
360
						<tr>
361
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
362
							<td width="78%" class="vtable">
363
								<select name='method' id='method' class="formselect" onchange='method_change()'>
364
								<?php
365
									foreach($cert_methods as $method => $desc):
366
									$selected = "";
367
									if ($pconfig['method'] == $method)
368
										$selected = "selected";
369
								?>
370
									<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option>
371
								<?php endforeach; ?>
372
								</select>
373
							</td>
374
						</tr>
375
						<?php endif; ?>
376
					</table>
377
378
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing">
379
						<tr>
380
							<td colspan="2" class="list" height="12"></td>
381
						</tr>
382
						<tr>
383
							<td colspan="2" valign="top" class="listtopic">Existing Certificate</td>
384
						</tr>
385
386
						<tr>
387
							<td width="22%" valign="top" class="vncellreq">Certificate data</td>
388
							<td width="78%" class="vtable">
389
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=$pconfig['cert'];?></textarea>
390
								<br>
391
								Paste a certificate in X.509 PEM format here.</td>
392
							</td>
393
						</tr>
394
						<tr>
395
							<td width="22%" valign="top" class="vncellreq">Private key data</td>
396
							<td width="78%" class="vtable">
397
								<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=$pconfig['key'];?></textarea>
398
								<br>
399
								Paste a private key in X.509 PEM format here.</td>
400
							</td>
401
						</tr>
402
					</table>
403
404
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal">
405
						<tr>
406
							<td colspan="2" class="list" height="12"></td>
407
						</tr>
408
						<tr>
409
							<td colspan="2" valign="top" class="listtopic">Internal Certificate</td>
410
						</tr>
411
412
						<?php if (!$internal_ca_count): ?>
413
414
						<tr>
415
							<td colspan="2" align="center" class="vtable">
416
								No internal Certificate Authorities have been defined. You must
417
								<a href="system_camanager.php?act=new&method=internal">create</a>
418
								an internal CA before creating an internal certificate.
419
							</td>
420
						</tr>
421
422
						<?php else: ?>
423
424
						<tr>
425
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
426
							<td width="78%" class="vtable">
427
								<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
428
								<?php
429
									foreach( $a_ca as $ca):
430
									if (!$ca['prv'])
431
										continue;
432
									$selected = "";
433
									if ($pconfig['caref'] == $ca['refid'])
434
										$selected = "selected";
435
								?>
436
									<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['name'];?></option>
437
								<?php endforeach; ?>
438
								</select>
439
							</td>
440
						</tr>
441
						<tr>
442
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
443
							<td width="78%" class="vtable">
444
								<select name='keylen' class="formselect">
445
								<?php
446
									foreach( $cert_keylens as $len):
447
									$selected = "";
448
									if ($pconfig['keylen'] == $len)
449
										$selected = "selected";
450
								?>
451
									<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
452
								<?php endforeach; ?>
453
								</select>
454
								bits
455
							</td>
456
						</tr>
457
						<tr>
458
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
459
							<td width="78%" class="vtable">
460
								<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
461
								days
462
							</td>
463
						</tr>
464
						<tr>
465
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
466
							<td width="78%" class="vtable">
467
								<table border="0" cellspacing="0" cellpadding="2">
468
									<tr>
469
										<td align="right">Country Code : &nbsp;</td>
470
										<td align="left">
471
											<input name="dn_country" type="text" class="formfld unknown" size="2" value="<?=htmlspecialchars($pconfig['dn_country']);?>" readonly/>
472
										</td>
473
									</tr>
474
									<tr>
475
										<td align="right">State or Province : &nbsp;</td>
476
										<td align="left">
477
											<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>" readonly/>
478
										</td>
479
									</tr>
480
									<tr>
481
										<td align="right">City : &nbsp;</td>
482
										<td align="left">
483
											<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>" readonly/>
484
										</td>
485
									</tr>
486
									<tr>
487
										<td align="right">Organization : &nbsp;</td>
488
										<td align="left">
489
											<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>" readonly/>
490
										</td>
491
									</tr>
492
									<tr>
493
										<td align="right">Email Address : &nbsp;</td>
494
										<td align="left">
495
											<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/>
496
											&nbsp;
497
											<em>ex:</em>
498
											&nbsp;
499
											webadmin@mycompany.com
500
										</td>
501
									</tr>
502
									<tr>
503
										<td align="right">Common Name : &nbsp;</td>
504
										<td align="left">
505
											<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/>
506
											&nbsp;
507
											<em>ex:</em>
508
											&nbsp;
509
											www.pfsense.org
510
										</td>
511
									</tr>
512
								</table>
513
							</td>
514
						</tr>
515 64cc39d3 Matthew Grooms
516
					<?php endif; ?>
517
518 96c7a492 Matthew Grooms
					</table>
519
520
					<table width="100%" border="0" cellpadding="6" cellspacing="0" id="external">
521
						<tr>
522
							<td colspan="2" class="list" height="12"></td>
523
						</tr>
524
						<tr>
525
							<td colspan="2" valign="top" class="listtopic">External Signing Request</td>
526
						</tr>
527
						<tr>
528
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
529
							<td width="78%" class="vtable">
530
								<select name='csr_keylen' class="formselect">
531
								<?php
532
									foreach( $cert_keylens as $len):
533
									$selected = "";
534
									if ($pconfig['keylen'] == $len)
535
										$selected = "selected";
536
								?>
537
									<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
538
								<?php endforeach; ?>
539
								</select>
540
								bits
541
							</td>
542
						</tr>
543
						<tr>
544
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
545
							<td width="78%" class="vtable">
546
								<table border="0" cellspacing="0" cellpadding="2">
547
									<tr>
548
										<td align="right">Country Code : &nbsp;</td>
549
										<td align="left">
550
											<input name="csr_dn_country" type="text" class="formfld unknown" size="2" value="<?=htmlspecialchars($pconfig['csr_dn_country']);?>" />
551
											&nbsp;
552
											<em>ex:</em>
553
											&nbsp;
554
											US
555
											&nbsp;
556
											<em>( two letters )</em>
557
										</td>
558
									</tr>
559
									<tr>
560
										<td align="right">State or Province : &nbsp;</td>
561
										<td align="left">
562
											<input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_state']);?>" />
563
											&nbsp;
564
											<em>ex:</em>
565
											&nbsp;
566
											Texas
567
										</td>
568
									</tr>
569
									<tr>
570
										<td align="right">City : &nbsp;</td>
571
										<td align="left">
572
											<input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_city']);?>" />
573
											&nbsp;
574
											<em>ex:</em>
575
											&nbsp;
576
											Austin
577
										</td>
578
									</tr>
579
									<tr>
580
										<td align="right">Organization : &nbsp;</td>
581
										<td align="left">
582
											<input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_organization']);?>" />
583
											&nbsp;
584
											<em>ex:</em>
585
											&nbsp;
586
											My Company Inc.
587
										</td>
588
									</tr>
589
									<tr>
590
										<td align="right">Email Address : &nbsp;</td>
591
										<td align="left">
592
											<input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_email']);?>"/>
593
											&nbsp;
594
											<em>ex:</em>
595
											&nbsp;
596
											webadmin@mycompany.com
597
										</td>
598
									</tr>
599
									<tr>
600
										<td align="right">Common Name : &nbsp;</td>
601
										<td align="left">
602
											<input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_commonname']);?>"/>
603
											&nbsp;
604
											<em>ex:</em>
605
											&nbsp;
606
											www.pfsense.org
607
										</td>
608
									</tr>
609
								</table>
610
							</td>
611
						</tr>
612
					</table>
613
614
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
615
						<tr>
616
							<td width="22%" valign="top">&nbsp;</td>
617
							<td width="78%">
618
								<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
619
								<?php if (isset($id) && $a_cert[$id]): ?>
620
								<input name="id" type="hidden" value="<?=$id;?>" />
621
								<?php endif;?>
622
							</td>
623
						</tr>
624
					</table>
625
				</form>
626
627
				<?php elseif ($act == "csr" || (($_POST['save'] == "Update") && $input_errors)):?>
628
629
				<form action="system_certmanager.php" method="post" name="iform" id="iform">
630
					<table width="100%" border="0" cellpadding="6" cellspacing="0">
631
						<tr>
632
							<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
633
							<td width="78%" class="vtable">
634
								<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
635
							</td>
636
						</tr>
637
						<tr>
638
							<td colspan="2" class="list" height="12"></td>
639
						</tr>
640
						<tr>
641
							<td colspan="2" valign="top" class="listtopic">Complete Signing Request</td>
642
						</tr>
643
644
						<tr>
645
							<td width="22%" valign="top" class="vncellreq">Signing Request data</td>
646
							<td width="78%" class="vtable">
647
								<textarea name="csr" id="csr" cols="65" rows="7" class="formfld_cert" readonly><?=$pconfig['csr'];?></textarea>
648
								<br>
649
								Copy the certificate signing data from here and forward it to your certificate authority for singing.</td>
650
							</td>
651
						</tr>
652
						<tr>
653
							<td width="22%" valign="top" class="vncellreq">Final Certificate data</td>
654
							<td width="78%" class="vtable">
655
								<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=$pconfig['cert'];?></textarea>
656
								<br>
657
								Paste the certificate received from your cerificate authority here.</td>
658
							</td>
659
						</tr>
660
						<tr>
661
							<td width="22%" valign="top">&nbsp;</td>
662
							<td width="78%">
663
								<input id="submit" name="save" type="submit" class="formbtn" value="Update" />
664
								<?php if (isset($id) && $a_cert[$id]): ?>
665
								<input name="id" type="hidden" value="<?=$id;?>" />
666
								<input name="act" type="hidden" value="csr" />
667
								<?php endif;?>
668
							</td>
669
						</tr>
670
					</table>
671
				</form>
672
673
				<?php else:?>
674
675
				<table width="100%" border="0" cellpadding="0" cellspacing="0">
676 64cc39d3 Matthew Grooms
					<tr>
677 96c7a492 Matthew Grooms
						<td width="20%" class="listhdrr">Name</td>
678
						<td width="20%" class="listhdrr">CA</td>
679
						<td width="40%" class="listhdrr">Distinguished Name</td>
680
						<td width="10%" class="list"></td>
681 64cc39d3 Matthew Grooms
					</tr>
682 96c7a492 Matthew Grooms
					<?php
683
						$i = 0;
684
						foreach($a_cert as $cert):
685
							$name = htmlspecialchars($cert['name']);
686
687
							if ($cert['crt']) {
688
								$subj = htmlspecialchars(cert_get_subject($cert['crt']));
689
								$caname = "<em>external</em>";
690
							}
691
692
							if ($cert['csr']) {
693
								$subj = htmlspecialchars(csr_get_subject($cert['csr']));
694
								$caname = "<em>external - signature pending</em>";
695
							}
696
697
							$ca = lookup_ca($cert['caref']);
698
							if ($ca)
699
								$caname = $ca['name'];
700
701
							if($cert['prv'])
702
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
703
							else
704
								$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
705
					?>
706 64cc39d3 Matthew Grooms
					<tr>
707 96c7a492 Matthew Grooms
						<td class="listlr">
708
							<table border="0" cellpadding="0" cellspacing="0">
709 64cc39d3 Matthew Grooms
								<tr>
710 96c7a492 Matthew Grooms
									<td align="left" valign="center">
711
										<img src="<?=$certimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
712 64cc39d3 Matthew Grooms
									</td>
713 96c7a492 Matthew Grooms
									<td align="left" valign="middle">
714
										<?=$name;?>
715 64cc39d3 Matthew Grooms
									</td>
716
								</tr>
717
							</table>
718
						</td>
719 96c7a492 Matthew Grooms
						<td class="listr"><?=$caname;?>&nbsp;</td>
720
						<td class="listr"><?=$subj;?>&nbsp;</td>
721
						<td valign="middle" nowrap class="list">
722
							<a href="system_certmanager.php?act=exp&id=<?=$i;?>")">
723
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="export cert" alt="export ca" width="17" height="17" border="0" />
724
							</a>
725
							<a href="system_certmanager.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate?");?>')">
726
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete cert" alt="delete cert" width="17" height="17" border="0" />
727
							</a>
728
							<?php	if ($cert['csr']): ?>
729
							&nbsp;
730
								<a href="system_certmanager.php?act=csr&id=<?=$i;?>">
731
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="update csr" alt="update csr" width="17" height="17" border="0" />
732
							</a>
733
							<?php	endif; ?>
734 64cc39d3 Matthew Grooms
						</td>
735
					</tr>
736 96c7a492 Matthew Grooms
					<?php
737
							$i++;
738
						endforeach;
739
					?>
740 64cc39d3 Matthew Grooms
					<tr>
741 96c7a492 Matthew Grooms
						<td class="list" colspan="3"></td>
742
						<td class="list">
743
							<a href="system_certmanager.php?act=new">
744
								<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add or import ca" alt="add ca" width="17" height="17" border="0" />
745
							</a>
746 64cc39d3 Matthew Grooms
						</td>
747
					</tr>
748
					<tr>
749 96c7a492 Matthew Grooms
						<td colspan="3">
750
							<p>
751
								<?=gettext("Additional certificates can be added here.");?>
752
							</p>
753 64cc39d3 Matthew Grooms
						</td>
754
					</tr>
755
				</table>
756
757 96c7a492 Matthew Grooms
				<?php endif; ?>
758 64cc39d3 Matthew Grooms
759 96c7a492 Matthew Grooms
			</div>
760 64cc39d3 Matthew Grooms
		</td>
761
	</tr>
762
</table>
763
<?php include("fend.inc");?>
764
<script type="text/javascript">
765
<!--
766
767
method_change();
768
internalca_change();
769
770
//-->
771
</script>
772
773
</body>