Project

General

Profile

Download (23.1 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 == "csr") {
92

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

    
98
	$pconfig['name'] = $a_cert[$id]['name'];
99
	$pconfig['csr'] = base64_decode($a_cert[$id]['csr']);
100
}
101

    
102
if ($_POST) {
103

    
104
	if ($_POST['save'] == "Save") {
105

    
106
		unset($input_errors);
107
		$pconfig = $_POST;
108

    
109
		/* input validation */
110
		if ($pconfig['method'] == "existing") {
111
			$reqdfields = explode(" ",
112
					"name cert key");
113
			$reqdfieldsn = explode(",",
114
					"Desriptive name,Certificate data,Key data");
115
		}
116

    
117
		if ($pconfig['method'] == "internal") {
118
			$reqdfields = explode(" ",
119
					"name caref keylen lifetime dn_country dn_state dn_city ".
120
					"dn_organization dn_email dn_commonname");
121
			$reqdfieldsn = explode(",",
122
					"Desriptive name,Certificate authority,Key length,Lifetime,".
123
					"Distinguished name Country Code,".
124
					"Distinguished name State or Province,".
125
					"Distinguished name City,".
126
					"Distinguished name Organization,".
127
					"Distinguished name Email Address,".
128
					"Distinguished name Common Name");
129
		}
130

    
131
		if ($pconfig['method'] == "external") {
132
			$reqdfields = explode(" ",
133
					"name csr_keylen csr_dn_country csr_dn_state csr_dn_city ".
134
					"csr_dn_organization csr_dn_email csr_dn_commonname");
135
			$reqdfieldsn = explode(",",
136
					"Desriptive name,Key length,".
137
					"Distinguished name Country Code,".
138
					"Distinguished name State or Province,".
139
					"Distinguished name City,".
140
					"Distinguished name Organization,".
141
					"Distinguished name Email Address,".
142
					"Distinguished name Common Name");
143
		}
144

    
145
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
146

    
147
		/* if this is an AJAX caller then handle via JSON */
148
		if (isAjax() && is_array($input_errors)) {
149
			input_errors2Ajax($input_errors);
150
			exit;
151
		}
152

    
153
		/* save modifications */
154
		if (!$input_errors) {
155

    
156
			$cert = array();
157
			$cert['refid'] = uniqid();
158
			if (isset($id) && $a_cert[$id])
159
				$cert = $a_cert[$id];
160

    
161
		    $cert['name'] = $pconfig['name'];
162

    
163
			if ($pconfig['method'] == "existing")
164
				cert_import($cert, $pconfig['cert'], $pconfig['key']);
165

    
166
			if ($pconfig['method'] == "internal") {
167
				$dn = array(
168
					'countryName' => $pconfig['dn_country'],
169
					'stateOrProvinceName' => $pconfig['dn_state'],
170
					'localityName' => $pconfig['dn_city'],
171
					'organizationName' => $pconfig['dn_organization'],
172
					'emailAddress' => $pconfig['dn_email'],
173
					'commonName' => $pconfig['dn_commonname']);
174

    
175
				cert_create($cert, $pconfig['caref'], $pconfig['keylen'],
176
					$pconfig['lifetime'], $dn);
177
			}
178

    
179
			if ($pconfig['method'] == "external") {
180
				$dn = array(
181
					'countryName' => $pconfig['csr_dn_country'],
182
					'stateOrProvinceName' => $pconfig['csr_dn_state'],
183
					'localityName' => $pconfig['csr_dn_city'],
184
					'organizationName' => $pconfig['csr_dn_organization'],
185
					'emailAddress' => $pconfig['csr_dn_email'],
186
					'commonName' => $pconfig['csr_dn_commonname']);
187

    
188
				csr_generate($cert, $pconfig['csr_keylen'], $dn);
189
			}
190

    
191
			if (isset($id) && $a_cert[$id])
192
				$a_cert[$id] = $cert;
193
			else
194
				$a_cert[] = $cert;
195

    
196
			write_config();
197

    
198
//			pfSenseHeader("system_certmanager.php");
199
		}
200
	}
201

    
202
	if ($_POST['save'] == "Update") {
203
		unset($input_errors);
204
		$pconfig = $_POST;
205

    
206
		/* input validation */
207
		$reqdfields = explode(" ", "name cert");
208
		$reqdfieldsn = explode(",", "Desriptive name,Final Certificate data");
209

    
210
		do_input_validation($_POST, $reqdfields, $reqdfieldsn, &$input_errors);
211

    
212
		/* make sure this csr and certificate subjects match */
213
		$subj_csr = csr_get_subject($pconfig['csr'], false);
214
		$subj_cert = cert_get_subject($pconfig['cert'], false);
215

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

    
219
		/* if this is an AJAX caller then handle via JSON */
220
		if (isAjax() && is_array($input_errors)) {
221
			input_errors2Ajax($input_errors);
222
			exit;
223
		}
224

    
225
		/* save modifications */
226
		if (!$input_errors) {
227

    
228
			$cert = $a_cert[$id];
229

    
230
			$cert['name'] = $pconfig['name'];
231

    
232
			csr_complete($cert, $pconfig['cert']);
233

    
234
			$a_cert[$id] = $cert;
235

    
236
			write_config();
237

    
238
			pfSenseHeader("system_certmanager.php");
239
		}
240
	}
241
}
242

    
243
include("head.inc");
244
?>
245

    
246
<body link="#000000" vlink="#000000" alink="#000000" onload="<?= $jsevents["body"]["onload"] ?>">
247
<?php include("fbegin.inc"); ?>
248
<script type="text/javascript">
249
<!--
250

    
251
function method_change() {
252

    
253
<?php
254
	if ($internal_ca_count)
255
		$submit_style = "";
256
	else
257
		$submit_style = "none";
258
?>
259

    
260
	method = document.iform.method.selectedIndex;
261

    
262
	switch (method) {
263
		case 0:
264
			document.getElementById("existing").style.display="";
265
			document.getElementById("internal").style.display="none";
266
			document.getElementById("external").style.display="none";
267
			break;
268
		case 1:
269
			document.getElementById("existing").style.display="none";
270
			document.getElementById("internal").style.display="";
271
			document.getElementById("external").style.display="none";
272
			document.getElementById("submit").style.display="<?=$submit_style;?>";
273
			break;
274
		case 2:
275
			document.getElementById("existing").style.display="none";
276
			document.getElementById("internal").style.display="none";
277
			document.getElementById("external").style.display="";
278
			break;
279
	}
280
}
281

    
282
<?php if ($internal_ca_count): ?>
283
function internalca_change() {
284

    
285
	index = document.iform.caref.selectedIndex;
286
	caref = document.iform.caref[index].value;
287

    
288
	switch (caref) {
289
<?php
290
		foreach ($a_ca as $ca):
291
			if (!$ca['prv'])
292
				continue;
293
			$subject = cert_get_subject_array($ca['crt']);
294
?>
295
		case "<?=$ca['refid'];?>":
296
			document.iform.dn_country.value = "<?=$subject[0]['v'];?>";
297
			document.iform.dn_state.value = "<?=$subject[1]['v'];?>";
298
			document.iform.dn_city.value = "<?=$subject[2]['v'];?>";
299
			document.iform.dn_organization.value = "<?=$subject[3]['v'];?>";
300
			break;
301
<?php	endforeach; ?>
302
	}
303
}
304
<?php endif; ?>
305

    
306
//-->
307
</script>
308
<?php
309
	if ($input_errors)
310
		print_input_errors($input_errors);
311
	if ($savemsg)
312
		print_info_box($savemsg);
313
?>
314
<table width="100%" border="0" cellpadding="0" cellspacing="0">
315
	<tr>
316
		<td class="tabnavtbl">
317
		<?php
318
			$tab_array = array();
319
			$tab_array[] = array(gettext("Users"), false, "system_usermanager.php");
320
			$tab_array[] = array(gettext("Groups"), false, "system_groupmanager.php");
321
			$tab_array[] = array(gettext("CAs"), false, "system_camanager.php");
322
			$tab_array[] = array(gettext("Certificates"), true, "system_certmanager.php");
323
			$tab_array[] = array(gettext("Servers"), false, "system_authservers.php");
324
			$tab_array[] = array(gettext("Settings"), false, "system_usermanager_settings.php");
325
			display_top_tabs($tab_array);
326
		?>
327
		</td>
328
	</tr>
329
	<tr>
330
		<td class="tabcont">
331

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

    
334
			<form action="system_certmanager.php" method="post" name="iform" id="iform">
335
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
336
					<tr>
337
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
338
						<td width="78%" class="vtable">
339
							<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
340
						</td>
341
					</tr>
342
					<?php if (!isset($id)): ?>
343
					<tr>
344
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td>
345
						<td width="78%" class="vtable">
346
							<select name='method' id='method' class="formselect" onchange='method_change()'>
347
							<?php
348
								foreach($cert_methods as $method => $desc):
349
								$selected = "";
350
								if ($pconfig['method'] == $method)
351
									$selected = "selected";
352
							?>
353
								<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option>
354
							<?php endforeach; ?>
355
							</select>
356
						</td>
357
					</tr>
358
					<?php endif; ?>
359
				</table>
360

    
361
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing">
362
					<tr>
363
						<td colspan="2" class="list" height="12"></td>
364
					</tr>
365
					<tr>
366
						<td colspan="2" valign="top" class="listtopic">Existing Certificate</td>
367
					</tr>
368

    
369
					<tr>
370
						<td width="22%" valign="top" class="vncellreq">Certificate data</td>
371
						<td width="78%" class="vtable">
372
							<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=$pconfig['cert'];?></textarea>
373
							<br>
374
							Paste a certificate in X.509 PEM format here.</td>
375
						</td>
376
					</tr>
377
					<tr>
378
						<td width="22%" valign="top" class="vncellreq">Private key data</td>
379
						<td width="78%" class="vtable">
380
							<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=$pconfig['key'];?></textarea>
381
							<br>
382
							Paste a private key in X.509 PEM format here.</td>
383
						</td>
384
					</tr>
385
				</table>
386

    
387
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal">
388
					<tr>
389
						<td colspan="2" class="list" height="12"></td>
390
					</tr>
391
					<tr>
392
						<td colspan="2" valign="top" class="listtopic">Internal Certificate</td>
393
					</tr>
394

    
395
					<?php if (!$internal_ca_count): ?>
396

    
397
					<tr>
398
						<td colspan="2" align="center" class="vtable">
399
							No internal Certificate Authorities have been defined. You must
400
							<a href="system_camanager.php?act=new&method=internal">create</a>
401
							an internal CA before creating an internal certificate.
402
						</td>
403
					</tr>
404

    
405
					<?php else: ?>
406

    
407
					<tr>
408
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate authority");?></td>
409
						<td width="78%" class="vtable">
410
							<select name='caref' id='caref' class="formselect" onChange='internalca_change()'>
411
							<?php
412
								foreach( $a_ca as $ca):
413
								if (!$ca['prv'])
414
									continue;
415
								$selected = "";
416
								if ($pconfig['caref'] == $ca['refid'])
417
									$selected = "selected";
418
							?>
419
								<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['name'];?></option>
420
							<?php endforeach; ?>
421
							</select>
422
						</td>
423
					</tr>
424
					<tr>
425
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
426
						<td width="78%" class="vtable">
427
							<select name='keylen' class="formselect">
428
							<?php
429
								foreach( $cert_keylens as $len):
430
								$selected = "";
431
								if ($pconfig['keylen'] == $len)
432
									$selected = "selected";
433
							?>
434
								<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
435
							<?php endforeach; ?>
436
							</select>
437
							bits
438
						</td>
439
					</tr>
440
					<tr>
441
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td>
442
						<td width="78%" class="vtable">
443
							<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/>
444
							days
445
						</td>
446
					</tr>
447
					<tr>
448
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
449
						<td width="78%" class="vtable">
450
							<table border="0" cellspacing="0" cellpadding="2">
451
								<tr>
452
									<td align="right">Country Code : &nbsp;</td>
453
									<td align="left">
454
										<input name="dn_country" type="text" class="formfld unknown" size="2" value="<?=htmlspecialchars($pconfig['dn_country']);?>" readonly/>
455
									</td>
456
								</tr>
457
								<tr>
458
									<td align="right">State or Province : &nbsp;</td>
459
									<td align="left">
460
										<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>" readonly/>
461
									</td>
462
								</tr>
463
								<tr>
464
									<td align="right">City : &nbsp;</td>
465
									<td align="left">
466
										<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>" readonly/>
467
									</td>
468
								</tr>
469
								<tr>
470
									<td align="right">Organization : &nbsp;</td>
471
									<td align="left">
472
										<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>" readonly/>
473
									</td>
474
								</tr>
475
								<tr>
476
									<td align="right">Email Address : &nbsp;</td>
477
									<td align="left">
478
										<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/>
479
										&nbsp;
480
										<em>ex:</em>
481
										&nbsp;
482
										webadmin@mycompany.com
483
									</td>
484
								</tr>
485
								<tr>
486
									<td align="right">Common Name : &nbsp;</td>
487
									<td align="left">
488
										<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/>
489
										&nbsp;
490
										<em>ex:</em>
491
										&nbsp;
492
										www.pfsense.org
493
									</td>
494
								</tr>
495
							</table>
496
						</td>
497
					</tr>
498

    
499
				<?php endif; ?>
500

    
501
				</table>
502

    
503
				<table width="100%" border="0" cellpadding="6" cellspacing="0" id="external">
504
					<tr>
505
						<td colspan="2" class="list" height="12"></td>
506
					</tr>
507
					<tr>
508
						<td colspan="2" valign="top" class="listtopic">External Signing Request</td>
509
					</tr>
510
					<tr>
511
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td>
512
						<td width="78%" class="vtable">
513
							<select name='csr_keylen' class="formselect">
514
							<?php
515
								foreach( $cert_keylens as $len):
516
								$selected = "";
517
								if ($pconfig['keylen'] == $len)
518
									$selected = "selected";
519
							?>
520
								<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option>
521
							<?php endforeach; ?>
522
							</select>
523
							bits
524
						</td>
525
					</tr>
526
					<tr>
527
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td>
528
						<td width="78%" class="vtable">
529
							<table border="0" cellspacing="0" cellpadding="2">
530
								<tr>
531
									<td align="right">Country Code : &nbsp;</td>
532
									<td align="left">
533
										<input name="csr_dn_country" type="text" class="formfld unknown" size="2" value="<?=htmlspecialchars($pconfig['csr_dn_country']);?>" />
534
										&nbsp;
535
										<em>ex:</em>
536
										&nbsp;
537
										US
538
										&nbsp;
539
										<em>( two letters )</em>
540
									</td>
541
								</tr>
542
								<tr>
543
									<td align="right">State or Province : &nbsp;</td>
544
									<td align="left">
545
										<input name="csr_dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_state']);?>" />
546
										&nbsp;
547
										<em>ex:</em>
548
										&nbsp;
549
										Texas
550
									</td>
551
								</tr>
552
								<tr>
553
									<td align="right">City : &nbsp;</td>
554
									<td align="left">
555
										<input name="csr_dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_city']);?>" />
556
										&nbsp;
557
										<em>ex:</em>
558
										&nbsp;
559
										Austin
560
									</td>
561
								</tr>
562
								<tr>
563
									<td align="right">Organization : &nbsp;</td>
564
									<td align="left">
565
										<input name="csr_dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['csr_dn_organization']);?>" />
566
										&nbsp;
567
										<em>ex:</em>
568
										&nbsp;
569
										My Company Inc.
570
									</td>
571
								</tr>
572
								<tr>
573
									<td align="right">Email Address : &nbsp;</td>
574
									<td align="left">
575
										<input name="csr_dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_email']);?>"/>
576
										&nbsp;
577
										<em>ex:</em>
578
										&nbsp;
579
										webadmin@mycompany.com
580
									</td>
581
								</tr>
582
								<tr>
583
									<td align="right">Common Name : &nbsp;</td>
584
									<td align="left">
585
										<input name="csr_dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['csr_dn_commonname']);?>"/>
586
										&nbsp;
587
										<em>ex:</em>
588
										&nbsp;
589
										www.pfsense.org
590
									</td>
591
								</tr>
592
							</table>
593
						</td>
594
					</tr>
595
				</table>
596

    
597
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
598
					<tr>
599
						<td width="22%" valign="top">&nbsp;</td>
600
						<td width="78%">
601
							<input id="submit" name="save" type="submit" class="formbtn" value="Save" />
602
							<?php if (isset($id) && $a_cert[$id]): ?>
603
							<input name="id" type="hidden" value="<?=$id;?>" />
604
							<?php endif;?>
605
						</td>
606
					</tr>
607
				</table>
608
			</form>
609

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

    
612
			<form action="system_certmanager.php" method="post" name="iform" id="iform">
613
				<table width="100%" border="0" cellpadding="6" cellspacing="0">
614
					<tr>
615
						<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td>
616
						<td width="78%" class="vtable">
617
							<input name="name" type="text" class="formfld unknown" id="name" size="20" value="<?=htmlspecialchars($pconfig['name']);?>"/>
618
						</td>
619
					</tr>
620
					<tr>
621
						<td colspan="2" class="list" height="12"></td>
622
					</tr>
623
					<tr>
624
						<td colspan="2" valign="top" class="listtopic">Complete Signing Request</td>
625
					</tr>
626

    
627
					<tr>
628
						<td width="22%" valign="top" class="vncellreq">Signing Request data</td>
629
						<td width="78%" class="vtable">
630
							<textarea name="csr" id="csr" cols="65" rows="7" class="formfld_cert" readonly><?=$pconfig['csr'];?></textarea>
631
							<br>
632
							Copy the certificate signing data from here and forward it to your certificate authority for singing.</td>
633
						</td>
634
					</tr>
635
					<tr>
636
						<td width="22%" valign="top" class="vncellreq">Final Certificate data</td>
637
						<td width="78%" class="vtable">
638
							<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=$pconfig['cert'];?></textarea>
639
							<br>
640
							Paste the certificate received from your cerificate authority here.</td>
641
						</td>
642
					</tr>
643
					<tr>
644
						<td width="22%" valign="top">&nbsp;</td>
645
						<td width="78%">
646
							<input id="submit" name="save" type="submit" class="formbtn" value="Update" />
647
							<?php if (isset($id) && $a_cert[$id]): ?>
648
							<input name="id" type="hidden" value="<?=$id;?>" />
649
							<input name="act" type="hidden" value="csr" />
650
							<?php endif;?>
651
						</td>
652
					</tr>
653
				</table>
654
			</form>
655

    
656
			<?php else:?>
657

    
658
			<table width="100%" border="0" cellpadding="0" cellspacing="0">
659
				<tr>
660
					<td width="20%" class="listhdrr">Name</td>
661
					<td width="20%" class="listhdrr">CA</td>
662
					<td width="40%" class="listhdrr">Distinguished Name</td>
663
					<td width="10%" class="list"></td>
664
				</tr>
665
				<?php
666
					$i = 0;
667
					foreach($a_cert as $cert):
668
						$name = htmlspecialchars($cert['name']);
669

    
670
						if ($cert['crt']) {
671
							$subj = htmlspecialchars(cert_get_subject($cert['crt']));
672
							$caname = "<em>external</em>";
673
						}
674

    
675
						if ($cert['csr']) {
676
							$subj = htmlspecialchars(csr_get_subject($cert['csr']));
677
							$caname = "<em>external - signature pending</em>";
678
						}
679

    
680
						$ca = lookup_ca($cert['caref']);
681
						if ($ca)
682
							$caname = $ca['name'];
683

    
684
						if($cert['prv'])
685
							$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
686
						else
687
							$certimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png";
688
				?>
689
				<tr>
690
					<td class="listlr">
691
						<table border="0" cellpadding="0" cellspacing="0">
692
							<tr>
693
								<td align="left" valign="center">
694
									<img src="<?=$certimg;?>" alt="CA" title="CA" border="0" height="16" width="16" />
695
								</td>
696
								<td align="left" valign="middle">
697
									<?=$name;?>
698
								</td>
699
							</tr>
700
						</table>
701
					</td>
702
					<td class="listr"><?=$caname;?>&nbsp;</td>
703
					<td class="listr"><?=$subj;?>&nbsp;</td>
704
					<td valign="middle" nowrap class="list">
705
						<a href="system_certmanager.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate?");?>')">
706
							<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="delete cert" alt="delete cert" width="17" height="17" border="0" />
707
						</a>
708
						<?php	if ($cert['csr']): ?>
709
						&nbsp;
710
						<a href="system_certmanager.php?act=csr&id=<?=$i;?>">
711
							<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="update csr" alt="update csr" width="17" height="17" border="0" />
712
						</a>
713
						<?php	endif; ?>
714
					</td>
715
				</tr>
716
				<?php
717
						$i++;
718
					endforeach;
719
				?>
720
				<tr>
721
					<td class="list" colspan="3"></td>
722
					<td class="list">
723
						<a href="system_certmanager.php?act=new">
724
							<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="add or import ca" alt="add ca" width="17" height="17" border="0" />
725
						</a>
726
					</td>
727
				</tr>
728
				<tr>
729
					<td colspan="3">
730
						<p>
731
							<?=gettext("Additional certificates can be added here.");?>
732
						</p>
733
					</td>
734
				</tr>
735
			</table>
736

    
737
			<?php endif; ?>
738

    
739
		</td>
740
	</tr>
741
</table>
742
<?php include("fend.inc");?>
743
<script type="text/javascript">
744
<!--
745

    
746
method_change();
747
internalca_change();
748

    
749
//-->
750
</script>
751

    
752
</body>
(166-166/215)