Revision 5d2edeca
Added by Sjon Hortensius over 10 years ago
usr/local/www/system_camanager.php | ||
---|---|---|
245 | 245 |
|
246 | 246 |
$ca['descr'] = $pconfig['descr']; |
247 | 247 |
|
248 |
if ($_POST['edit'] == "edit") {
|
|
248 |
if ($act == "edit") {
|
|
249 | 249 |
$ca['descr'] = $pconfig['descr']; |
250 | 250 |
$ca['refid'] = $pconfig['refid']; |
251 | 251 |
$ca['serial'] = $pconfig['serial']; |
252 |
$ca['crt'] = base64_encode($pconfig['cert']);
|
|
252 |
$ca['crt'] = base64_encode($pconfig['cert']); |
|
253 | 253 |
if (!empty($pconfig['key'])) |
254 |
$ca['prv'] = base64_encode($pconfig['key']);
|
|
254 |
$ca['prv'] = base64_encode($pconfig['key']); |
|
255 | 255 |
} else { |
256 | 256 |
$old_err_level = error_reporting(0); /* otherwise openssl_ functions throw warnings directly to a page screwing menu tab */ |
257 | 257 |
if ($pconfig['method'] == "existing") |
... | ... | |
303 | 303 |
} |
304 | 304 |
|
305 | 305 |
include("head.inc"); |
306 |
?> |
|
307 | 306 |
|
308 |
<body link="#0000CC" vlink="#0000CC" alink="#0000CC" onload="<?= $jsevents["body"]["onload"] ?>"> |
|
309 |
<?php include("fbegin.inc"); ?> |
|
310 |
<script type="text/javascript"> |
|
311 |
//<![CDATA[ |
|
312 |
|
|
313 |
function method_change() { |
|
314 |
|
|
315 |
method = document.iform.method.selectedIndex; |
|
316 |
|
|
317 |
switch (method) { |
|
318 |
case 0: |
|
319 |
document.getElementById("existing").style.display=""; |
|
320 |
document.getElementById("internal").style.display="none"; |
|
321 |
document.getElementById("intermediate").style.display="none"; |
|
322 |
break; |
|
323 |
case 1: |
|
324 |
document.getElementById("existing").style.display="none"; |
|
325 |
document.getElementById("internal").style.display=""; |
|
326 |
document.getElementById("intermediate").style.display="none"; |
|
327 |
break; |
|
328 |
case 2: |
|
329 |
document.getElementById("existing").style.display="none"; |
|
330 |
document.getElementById("internal").style.display=""; |
|
331 |
document.getElementById("intermediate").style.display=""; |
|
332 |
break; |
|
333 |
} |
|
307 |
if ($input_errors) |
|
308 |
print_input_errors($input_errors); |
|
309 |
if ($savemsg) |
|
310 |
print_info_box($savemsg); |
|
311 |
|
|
312 |
// Load valid country codes |
|
313 |
$dn_cc = array(); |
|
314 |
if (file_exists("/etc/ca_countries")){ |
|
315 |
$dn_cc_file=file("/etc/ca_countries"); |
|
316 |
foreach($dn_cc_file as $line) |
|
317 |
if (preg_match('/^(\S*)\s(.*)$/', $line, $matches)) |
|
318 |
array_push($dn_cc, $matches[1]); |
|
334 | 319 |
} |
335 | 320 |
|
336 |
//]]> |
|
337 |
</script> |
|
321 |
$tab_array = array(); |
|
322 |
$tab_array[] = array(gettext("CAs"), true, "system_camanager.php"); |
|
323 |
$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php"); |
|
324 |
$tab_array[] = array(gettext("Certificate Revocation"), false, "system_crlmanager.php"); |
|
325 |
display_top_tabs($tab_array); |
|
326 |
|
|
327 |
if (!($act == "new" || $act == "edit" || $act == gettext("Save") || $input_errors)) |
|
328 |
{ |
|
329 |
?> |
|
330 |
<div class="table-responsive"> |
|
331 |
<table class="table table-striped table-hover"> |
|
332 |
<thead> |
|
333 |
<tr> |
|
334 |
<th><?=gettext("Name")?></th> |
|
335 |
<th><?=gettext("Internal")?></th> |
|
336 |
<th><?=gettext("Issuer")?></th> |
|
337 |
<th><?=gettext("Certificates")?></th> |
|
338 |
<th><?=gettext("Distinguished Name")?></th> |
|
339 |
<th></th> |
|
340 |
</tr> |
|
341 |
</thead> |
|
342 |
<tbody> |
|
338 | 343 |
<?php |
339 |
if ($input_errors) |
|
340 |
print_input_errors($input_errors); |
|
341 |
if ($savemsg) |
|
342 |
print_info_box($savemsg); |
|
343 |
|
|
344 |
// Load valid country codes |
|
345 |
$dn_cc = array(); |
|
346 |
if (file_exists("/etc/ca_countries")){ |
|
347 |
$dn_cc_file=file("/etc/ca_countries"); |
|
348 |
foreach($dn_cc_file as $line) |
|
349 |
if (preg_match('/^(\S*)\s(.*)$/', $line, $matches)) |
|
350 |
array_push($dn_cc, $matches[1]); |
|
351 |
} |
|
344 |
foreach ($a_ca as $i => $ca): |
|
345 |
$name = htmlspecialchars($ca['descr']); |
|
346 |
$subj = cert_get_subject($ca['crt']); |
|
347 |
$issuer = cert_get_issuer($ca['crt']); |
|
348 |
list($startdate, $enddate) = cert_get_dates($ca['crt']); |
|
349 |
if($subj == $issuer) |
|
350 |
$issuer_name = "<em>" . gettext("self-signed") . "</em>"; |
|
351 |
else |
|
352 |
$issuer_name = "<em>" . gettext("external") . "</em>"; |
|
353 |
$subj = htmlspecialchars($subj); |
|
354 |
$issuer = htmlspecialchars($issuer); |
|
355 |
$certcount = 0; |
|
356 |
|
|
357 |
$issuer_ca = lookup_ca($ca['caref']); |
|
358 |
if ($issuer_ca) |
|
359 |
$issuer_name = $issuer_ca['descr']; |
|
360 |
|
|
361 |
// TODO : Need gray certificate icon |
|
362 |
$internal = (!!$ca['prv']); |
|
363 |
|
|
364 |
foreach ($a_cert as $cert) |
|
365 |
if ($cert['caref'] == $ca['refid']) |
|
366 |
$certcount++; |
|
367 |
|
|
368 |
foreach ($a_ca as $cert) |
|
369 |
if ($cert['caref'] == $ca['refid']) |
|
370 |
$certcount++; |
|
352 | 371 |
?> |
353 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary="CA manager"> |
|
354 |
<tr> |
|
355 |
<td> |
|
356 |
<?php |
|
357 |
$tab_array = array(); |
|
358 |
$tab_array[] = array(gettext("CAs"), true, "system_camanager.php"); |
|
359 |
$tab_array[] = array(gettext("Certificates"), false, "system_certmanager.php"); |
|
360 |
$tab_array[] = array(gettext("Certificate Revocation"), false, "system_crlmanager.php"); |
|
361 |
display_top_tabs($tab_array); |
|
362 |
?> |
|
363 |
</td> |
|
364 |
</tr> |
|
365 |
<tr> |
|
366 |
<td id="mainarea"> |
|
367 |
<div class="tabcont"> |
|
368 |
|
|
369 |
<?php if ($act == "new" || $act == "edit" || $act == gettext("Save") || $input_errors): ?> |
|
370 |
|
|
371 |
<form action="system_camanager.php" method="post" name="iform" id="iform"> |
|
372 |
<?php if ($act == "edit"): ?> |
|
373 |
<input type="hidden" name="edit" value="edit" id="edit" /> |
|
374 |
<input type="hidden" name="id" value="<?php echo htmlspecialchars($id); ?>" id="id" /> |
|
375 |
<input type="hidden" name="refid" value="<?php echo $pconfig['refid']; ?>" id="refid" /> |
|
376 |
<?php endif; ?> |
|
377 |
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="main area"> |
|
378 |
<tr> |
|
379 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Descriptive name");?></td> |
|
380 |
<td width="78%" class="vtable"> |
|
381 |
<input name="descr" type="text" class="formfld unknown" id="descr" size="20" value="<?=htmlspecialchars($pconfig['descr']);?>"/> |
|
382 |
</td> |
|
383 |
</tr> |
|
384 |
<?php if (!isset($id) || $act == "edit"): ?> |
|
385 |
<tr> |
|
386 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Method");?></td> |
|
387 |
<td width="78%" class="vtable"> |
|
388 |
<select name='method' id='method' class="formselect" onchange='method_change()'> |
|
389 |
<?php |
|
390 |
foreach($ca_methods as $method => $desc): |
|
391 |
$selected = ""; |
|
392 |
if ($pconfig['method'] == $method) |
|
393 |
$selected = " selected=\"selected\""; |
|
394 |
?> |
|
395 |
<option value="<?=$method;?>"<?=$selected;?>><?=$desc;?></option> |
|
396 |
<?php endforeach; ?> |
|
397 |
</select> |
|
398 |
</td> |
|
399 |
</tr> |
|
400 |
<?php endif; ?> |
|
401 |
</table> |
|
402 |
|
|
403 |
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="existing" summary="existing"> |
|
404 |
<tr> |
|
405 |
<td colspan="2" class="list" height="12"></td> |
|
406 |
</tr> |
|
407 |
<tr> |
|
408 |
<td colspan="2" valign="top" class="listtopic"><?=gettext("Existing Certificate Authority");?></td> |
|
409 |
</tr> |
|
410 |
|
|
411 |
<tr> |
|
412 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate data");?></td> |
|
413 |
<td width="78%" class="vtable"> |
|
414 |
<textarea name="cert" id="cert" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['cert']);?></textarea> |
|
415 |
<br /> |
|
416 |
<?=gettext("Paste a certificate in X.509 PEM format here.");?> |
|
417 |
</td> |
|
418 |
</tr> |
|
419 |
<tr> |
|
420 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Certificate Private Key");?><br /><?=gettext("(optional)");?></td> |
|
421 |
<td width="78%" class="vtable"> |
|
422 |
<textarea name="key" id="key" cols="65" rows="7" class="formfld_cert"><?=htmlspecialchars($pconfig['key']);?></textarea> |
|
423 |
<br /> |
|
424 |
<?=gettext("Paste the private key for the above certificate here. This is optional in most cases, but required if you need to generate a Certificate Revocation List (CRL).");?> |
|
425 |
</td> |
|
426 |
</tr> |
|
427 |
|
|
428 |
<?php if (!isset($id) || $act == "edit"): ?> |
|
429 |
<tr> |
|
430 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Serial for next certificate");?></td> |
|
431 |
<td width="78%" class="vtable"> |
|
432 |
<input name="serial" type="text" class="formfld unknown" id="serial" size="20" value="<?=htmlspecialchars($pconfig['serial']);?>"/> |
|
433 |
<br /><?=gettext("Enter a decimal number to be used as the serial number for the next certificate to be created using this CA.");?> |
|
434 |
</td> |
|
435 |
</tr> |
|
436 |
<?php endif; ?> |
|
437 |
</table> |
|
438 |
|
|
439 |
<table width="100%" border="0" cellpadding="6" cellspacing="0" id="internal" summary="internal"> |
|
440 |
<tr> |
|
441 |
<td colspan="2" class="list" height="12"></td> |
|
442 |
</tr> |
|
443 |
<tr> |
|
444 |
<td colspan="2" valign="top" class="listtopic"><?=gettext("Internal Certificate Authority");?></td> |
|
445 |
</tr> |
|
446 |
<tr id='intermediate'> |
|
447 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Signing Certificate Authority");?></td> |
|
448 |
<td width="78%" class="vtable"> |
|
449 |
<select name='caref' id='caref' class="formselect" onchange='internalca_change()'> |
|
450 |
<?php |
|
451 |
foreach( $a_ca as $ca): |
|
452 |
if (!$ca['prv']) |
|
453 |
continue; |
|
454 |
$selected = ""; |
|
455 |
if ($pconfig['caref'] == $ca['refid']) |
|
456 |
$selected = " selected=\"selected\""; |
|
457 |
?> |
|
458 |
<option value="<?=$ca['refid'];?>"<?=$selected;?>><?=$ca['descr'];?></option> |
|
459 |
<?php endforeach; ?> |
|
460 |
</select> |
|
461 |
</td> |
|
462 |
</tr> |
|
463 |
<tr> |
|
464 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Key length");?></td> |
|
465 |
<td width="78%" class="vtable"> |
|
466 |
<select name='keylen' id='keylen' class="formselect"> |
|
467 |
<?php |
|
468 |
foreach( $ca_keylens as $len): |
|
469 |
$selected = ""; |
|
470 |
if ($pconfig['keylen'] == $len) |
|
471 |
$selected = " selected=\"selected\""; |
|
472 |
?> |
|
473 |
<option value="<?=$len;?>"<?=$selected;?>><?=$len;?></option> |
|
474 |
<?php endforeach; ?> |
|
475 |
</select> |
|
476 |
<?=gettext("bits");?> |
|
477 |
</td> |
|
478 |
</tr> |
|
479 |
<tr> |
|
480 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Digest Algorithm");?></td> |
|
481 |
<td width="78%" class="vtable"> |
|
482 |
<select name='digest_alg' id='digest_alg' class="formselect"> |
|
483 |
<?php |
|
484 |
foreach( $openssl_digest_algs as $digest_alg): |
|
485 |
$selected = ""; |
|
486 |
if ($pconfig['digest_alg'] == $digest_alg) |
|
487 |
$selected = " selected=\"selected\""; |
|
488 |
?> |
|
489 |
<option value="<?=$digest_alg;?>"<?=$selected;?>><?=strtoupper($digest_alg);?></option> |
|
490 |
<?php endforeach; ?> |
|
491 |
</select> |
|
492 |
<br /><?= gettext("NOTE: It is recommended to use an algorithm stronger than SHA1 when possible.") ?> |
|
493 |
</td> |
|
494 |
</tr> |
|
495 |
<tr> |
|
496 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Lifetime");?></td> |
|
497 |
<td width="78%" class="vtable"> |
|
498 |
<input name="lifetime" type="text" class="formfld unknown" id="lifetime" size="5" value="<?=htmlspecialchars($pconfig['lifetime']);?>"/> |
|
499 |
<?=gettext("days");?> |
|
500 |
</td> |
|
501 |
</tr> |
|
502 |
<tr> |
|
503 |
<td width="22%" valign="top" class="vncellreq"><?=gettext("Distinguished name");?></td> |
|
504 |
<td width="78%" class="vtable"> |
|
505 |
<table border="0" cellspacing="0" cellpadding="2" summary="name"> |
|
506 |
<tr> |
|
507 |
<td align="right"><?=gettext("Country Code");?> : </td> |
|
508 |
<td align="left"> |
|
509 |
<select name='dn_country' class="formselect"> |
|
510 |
<?php |
|
511 |
foreach( $dn_cc as $cc){ |
|
512 |
$selected = ""; |
|
513 |
if ($pconfig['dn_country'] == $cc) |
|
514 |
$selected = " selected=\"selected\""; |
|
515 |
print "<option value=\"$cc\"$selected>$cc</option>"; |
|
516 |
} |
|
517 |
?> |
|
518 |
</select> |
|
519 |
</td> |
|
520 |
</tr> |
|
521 |
<tr> |
|
522 |
<td align="right"><?=gettext("State or Province");?> : </td> |
|
523 |
<td align="left"> |
|
524 |
<input name="dn_state" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_state']);?>"/> |
|
525 |
|
|
526 |
<em><?=gettext("ex:");?></em> |
|
527 |
|
|
528 |
<?=gettext("Texas");?> |
|
529 |
</td> |
|
530 |
</tr> |
|
531 |
<tr> |
|
532 |
<td align="right"><?=gettext("City");?> : </td> |
|
533 |
<td align="left"> |
|
534 |
<input name="dn_city" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_city']);?>"/> |
|
535 |
|
|
536 |
<em><?=gettext("ex:");?></em> |
|
537 |
|
|
538 |
<?=gettext("Austin");?> |
|
539 |
</td> |
|
540 |
</tr> |
|
541 |
<tr> |
|
542 |
<td align="right"><?=gettext("Organization");?> : </td> |
|
543 |
<td align="left"> |
|
544 |
<input name="dn_organization" type="text" class="formfld unknown" size="40" value="<?=htmlspecialchars($pconfig['dn_organization']);?>"/> |
|
545 |
|
|
546 |
<em><?=gettext("ex:");?></em> |
|
547 |
|
|
548 |
<?=gettext("My Company Inc.");?> |
|
549 |
</td> |
|
550 |
</tr> |
|
551 |
<tr> |
|
552 |
<td align="right"><?=gettext("Email Address");?> : </td> |
|
553 |
<td align="left"> |
|
554 |
<input name="dn_email" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_email']);?>"/> |
|
555 |
|
|
556 |
<em><?=gettext("ex:");?></em> |
|
557 |
|
|
558 |
<?=gettext("admin@mycompany.com");?> |
|
559 |
</td> |
|
560 |
</tr> |
|
561 |
<tr> |
|
562 |
<td align="right"><?=gettext("Common Name");?> : </td> |
|
563 |
<td align="left"> |
|
564 |
<input name="dn_commonname" type="text" class="formfld unknown" size="25" value="<?=htmlspecialchars($pconfig['dn_commonname']);?>"/> |
|
565 |
|
|
566 |
<em><?=gettext("ex:");?></em> |
|
567 |
|
|
568 |
<?=gettext("internal-ca");?> |
|
569 |
</td> |
|
570 |
</tr> |
|
571 |
</table> |
|
572 |
</td> |
|
573 |
</tr> |
|
574 |
</table> |
|
575 |
|
|
576 |
<table width="100%" border="0" cellpadding="6" cellspacing="0" summary="save"> |
|
577 |
<tr> |
|
578 |
<td width="22%" valign="top"> </td> |
|
579 |
<td width="78%"> |
|
580 |
<input id="submit" name="save" type="submit" class="formbtn" value="<?=gettext("Save"); ?>" /> |
|
581 |
<?php if (isset($id) && $a_ca[$id]): ?> |
|
582 |
<input name="id" type="hidden" value="<?=htmlspecialchars($id);?>" /> |
|
583 |
<?php endif;?> |
|
584 |
</td> |
|
585 |
</tr> |
|
586 |
</table> |
|
587 |
</form> |
|
588 |
|
|
589 |
<?php else: ?> |
|
590 |
|
|
591 |
<table width="100%" border="0" cellpadding="0" cellspacing="0" summary=""> |
|
592 |
<tr> |
|
593 |
<td width="20%" class="listhdrr"><?=gettext("Name");?></td> |
|
594 |
<td width="10%" class="listhdrr"><?=gettext("Internal");?></td> |
|
595 |
<td width="10%" class="listhdrr"><?=gettext("Issuer");?></td> |
|
596 |
<td width="10%" class="listhdrr"><?=gettext("Certificates");?></td> |
|
597 |
<td width="40%" class="listhdrr"><?=gettext("Distinguished Name");?></td> |
|
598 |
<td width="10%" class="list"></td> |
|
599 |
</tr> |
|
600 |
<?php |
|
601 |
$i = 0; |
|
602 |
foreach($a_ca as $ca): |
|
603 |
$name = htmlspecialchars($ca['descr']); |
|
604 |
$subj = cert_get_subject($ca['crt']); |
|
605 |
$issuer = cert_get_issuer($ca['crt']); |
|
606 |
list($startdate, $enddate) = cert_get_dates($ca['crt']); |
|
607 |
if($subj == $issuer) |
|
608 |
$issuer_name = "<em>" . gettext("self-signed") . "</em>"; |
|
609 |
else |
|
610 |
$issuer_name = "<em>" . gettext("external") . "</em>"; |
|
611 |
$subj = htmlspecialchars($subj); |
|
612 |
$issuer = htmlspecialchars($issuer); |
|
613 |
$certcount = 0; |
|
614 |
|
|
615 |
$issuer_ca = lookup_ca($ca['caref']); |
|
616 |
if ($issuer_ca) |
|
617 |
$issuer_name = $issuer_ca['descr']; |
|
618 |
|
|
619 |
// TODO : Need gray certificate icon |
|
620 |
|
|
621 |
if($ca['prv']) { |
|
622 |
$caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; |
|
623 |
$internal = "YES"; |
|
624 |
|
|
625 |
} else { |
|
626 |
$caimg = "/themes/{$g['theme']}/images/icons/icon_frmfld_cert.png"; |
|
627 |
$internal = "NO"; |
|
628 |
} |
|
629 |
foreach ($a_cert as $cert) |
|
630 |
if ($cert['caref'] == $ca['refid']) |
|
631 |
$certcount++; |
|
632 |
foreach ($a_ca as $cert) |
|
633 |
if ($cert['caref'] == $ca['refid']) |
|
634 |
$certcount++; |
|
635 |
?> |
|
636 |
<tr> |
|
637 |
<td class="listlr"> |
|
638 |
<table border="0" cellpadding="0" cellspacing="0" summary="icon"> |
|
639 |
<tr> |
|
640 |
<td align="left" valign="middle"> |
|
641 |
<img src="<?=$caimg;?>" alt="CA" title="CA" border="0" height="16" width="16" /> |
|
642 |
</td> |
|
643 |
<td align="left" valign="middle"> |
|
644 |
<?=$name;?> |
|
645 |
</td> |
|
646 |
</tr> |
|
647 |
</table> |
|
648 |
</td> |
|
649 |
<td class="listr"><?=$internal;?> </td> |
|
650 |
<td class="listr"><?=$issuer_name;?> </td> |
|
651 |
<td class="listr"><?=$certcount;?> </td> |
|
652 |
<td class="listr"><?=$subj;?><br /> |
|
653 |
<table width="100%" style="font-size: 9px" summary="valid"> |
|
654 |
<tr> |
|
655 |
<td width="10%"> </td> |
|
656 |
<td width="20%"><?=gettext("Valid From")?>:</td> |
|
657 |
<td width="70%"><?= $startdate ?></td> |
|
658 |
</tr> |
|
659 |
<tr> |
|
660 |
<td> </td> |
|
661 |
<td><?=gettext("Valid Until")?>:</td> |
|
662 |
<td><?= $enddate ?></td> |
|
663 |
</tr> |
|
664 |
</table> |
|
665 |
</td> |
|
666 |
<td valign="middle" class="list nowrap"> |
|
667 |
<a href="system_camanager.php?act=edit&id=<?=$i;?>"> |
|
668 |
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_e.gif" title="<?=gettext("edit CA");?>" alt="<?=gettext("edit CA");?>" width="17" height="17" border="0" /> |
|
669 |
</a> |
|
670 |
<a href="system_camanager.php?act=exp&id=<?=$i;?>"> |
|
671 |
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export CA cert");?>" alt="<?=gettext("export CA cert");?>" width="17" height="17" border="0" /> |
|
672 |
</a> |
|
673 |
<?php if ($ca['prv']): ?> |
|
674 |
<a href="system_camanager.php?act=expkey&id=<?=$i;?>"> |
|
675 |
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_down.gif" title="<?=gettext("export CA private key");?>" alt="<?=gettext("export CA private key");?>" width="17" height="17" border="0" /> |
|
676 |
</a> |
|
677 |
<?php endif; ?> |
|
678 |
<a href="system_camanager.php?act=del&id=<?=$i;?>" onclick="return confirm('<?=gettext("Do you really want to delete this Certificate Authority and its CRLs, and unreference any associated certificates?");?>')"> |
|
679 |
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_x.gif" title="<?=gettext("delete ca");?>" alt="<?=gettext("delete ca"); ?>" width="17" height="17" border="0" /> |
|
680 |
</a> |
|
681 |
</td> |
|
682 |
</tr> |
|
683 |
<?php |
|
684 |
$i++; |
|
685 |
endforeach; |
|
686 |
?> |
|
372 |
<tr> |
|
373 |
<td><?=$name?></td> |
|
374 |
<td><?=$internal?></td> |
|
375 |
<td><?=$issuer_name?></td> |
|
376 |
<td><?=$certcount?></td> |
|
377 |
<td><?=$subj?><br /> |
|
378 |
<table> |
|
687 | 379 |
<tr> |
688 |
<td class="list" colspan="5"></td> |
|
689 |
<td class="list"> |
|
690 |
<a href="system_camanager.php?act=new"> |
|
691 |
<img src="/themes/<?= $g['theme'];?>/images/icons/icon_plus.gif" title="<?=gettext("add or import ca");?>" alt="<?=gettext("add ca");?>" width="17" height="17" border="0" /> |
|
692 |
</a> |
|
693 |
</td> |
|
380 |
<td> </td> |
|
381 |
<td><?=gettext("Valid From")?>:</td> |
|
382 |
<td><?=$startdate ?></td> |
|
694 | 383 |
</tr> |
695 | 384 |
<tr> |
696 |
<td colspan="5"> |
|
697 |
<p> |
|
698 |
<?=gettext("Additional trusted Certificate Authorities can be added here.");?> |
|
699 |
</p> |
|
700 |
</td> |
|
385 |
<td> </td> |
|
386 |
<td><?=gettext("Valid Until")?>:</td> |
|
387 |
<td><?=$enddate ?></td> |
|
701 | 388 |
</tr> |
702 | 389 |
</table> |
390 |
</td> |
|
391 |
<td> |
|
392 |
<a href="system_camanager.php?act=edit&id=<?=$i?>" class="btn btn-xs btn-primary"> |
|
393 |
<?=gettext("edit")?> |
|
394 |
</a> |
|
395 |
<a href="system_camanager.php?act=exp&id=<?=$i?>" class="btn btn-xs btn-default"> |
|
396 |
<?=gettext("export cert")?> |
|
397 |
</a> |
|
398 |
<?php if ($ca['prv']): ?> |
|
399 |
<a href="system_camanager.php?act=expkey&id=<?=$i?>" class="btn btn-xs btn-default"> |
|
400 |
<?=gettext("export private key")?> |
|
401 |
</a> |
|
402 |
<?php endif?> |
|
403 |
<a href="system_camanager.php?act=del&id=<?=$i?>" class="btn btn-xs btn-danger"> |
|
404 |
<?=gettext("delete")?> |
|
405 |
</a> |
|
406 |
</td> |
|
407 |
</tr> |
|
408 |
<?php endforeach; ?> |
|
409 |
</tbody> |
|
410 |
</table> |
|
703 | 411 |
|
704 |
<?php endif; ?> |
|
412 |
<nav class="action-buttons"> |
|
413 |
<a href="?act=new" class="btn btn-success">add new</a> |
|
414 |
</nav> |
|
415 |
<? |
|
416 |
include("foot.inc"); |
|
417 |
exit; |
|
418 |
} |
|
705 | 419 |
|
706 |
</div> |
|
707 |
</td> |
|
708 |
</tr> |
|
709 |
</table> |
|
710 |
<?php include("fend.inc");?> |
|
711 |
<script type="text/javascript"> |
|
712 |
//<![CDATA[ |
|
420 |
require('classes/Form.class.php'); |
|
421 |
$form = new Form; |
|
422 |
$form->setAction('system_camanager.php?act=edit'); |
|
423 |
if (isset($id) && $a_ca[$id]) |
|
424 |
{ |
|
425 |
$form->addGlobal(new Form_Input( |
|
426 |
'id', |
|
427 |
null, |
|
428 |
'hidden', |
|
429 |
$id |
|
430 |
)); |
|
431 |
} |
|
713 | 432 |
|
714 |
method_change(); |
|
433 |
if ($act == "edit") |
|
434 |
{ |
|
435 |
$form->addGlobal(new Form_Input( |
|
436 |
'refid', |
|
437 |
null, |
|
438 |
'hidden', |
|
439 |
$pconfig['refid'] |
|
440 |
)); |
|
441 |
} |
|
442 |
|
|
443 |
$section = new Form_Section('Create / edit CA'); |
|
444 |
|
|
445 |
$section->addInput(new Form_Input( |
|
446 |
'descr', |
|
447 |
'Descriptive name', |
|
448 |
'text', |
|
449 |
$pconfig['descr'] |
|
450 |
)); |
|
451 |
|
|
452 |
if (!isset($id) || $act == "edit") |
|
453 |
{ |
|
454 |
$section->addInput(new Form_Select( |
|
455 |
'method', |
|
456 |
'Method', |
|
457 |
$pconfig['method'], |
|
458 |
$ca_methods |
|
459 |
))->toggles(null); |
|
460 |
} |
|
715 | 461 |
|
716 |
//]]> |
|
717 |
</script> |
|
462 |
$form->add($section); |
|
463 |
|
|
464 |
$section = new Form_Section('Existing Certificate Authority'); |
|
465 |
$section->addClass('toggle-existing collapse'); |
|
466 |
|
|
467 |
$section->addInput(new Form_Textarea( |
|
468 |
'cert', |
|
469 |
'Certificate data', |
|
470 |
$pconfig['cert'] |
|
471 |
))->setHelp('Paste a certificate in X.509 PEM format here.'); |
|
472 |
|
|
473 |
$section->addInput(new Form_Textarea( |
|
474 |
'key', |
|
475 |
'Certificate Private Key (optional)', |
|
476 |
$pconfig['key'] |
|
477 |
))->setHelp('Paste the private key for the above certificate here. This is '. |
|
478 |
'optional in most cases, but required if you need to generate a '. |
|
479 |
'Certificate Revocation List (CRL).'); |
|
480 |
|
|
481 |
$section->addInput(new Form_Input( |
|
482 |
'serial', |
|
483 |
'Serial for next certificate', |
|
484 |
'number', |
|
485 |
$pconfig['serial'] |
|
486 |
))->setHelp('Enter a decimal number to be used as the serial number for the next '. |
|
487 |
'certificate to be created using this CA.'); |
|
488 |
|
|
489 |
$form->add($section); |
|
490 |
|
|
491 |
$section = new Form_Section('Internal Certificate Authority'); |
|
492 |
$section->addClass('toggle-internal', 'toggle-intermediate', 'collapse'); |
|
493 |
|
|
494 |
$allCas = array(); |
|
495 |
foreach ($a_ca as $ca) |
|
496 |
{ |
|
497 |
if (!$ca['prv']) |
|
498 |
continue; |
|
499 |
|
|
500 |
$allCas[ $ca['refid'] ] = $ca['descr']; |
|
501 |
} |
|
718 | 502 |
|
719 |
</body> |
|
720 |
</html> |
|
503 |
$group = new Form_Group('Signing Certificate Authority'); |
|
504 |
$group->addClass('toggle-intermediate'); |
|
505 |
$group->add(new Form_Select( |
|
506 |
'caref', |
|
507 |
null, |
|
508 |
$pconfig['caref'], |
|
509 |
$allCas |
|
510 |
)); |
|
511 |
$section->add($group); |
|
512 |
|
|
513 |
$section->addInput(new Form_Select( |
|
514 |
'keylen', |
|
515 |
'Key length (bits)', |
|
516 |
$pconfig['keylen'], |
|
517 |
$ca_keylens |
|
518 |
)); |
|
519 |
|
|
520 |
$section->addInput(new Form_Select( |
|
521 |
'digest_alg', |
|
522 |
'Digest Algorithm', |
|
523 |
$pconfig['digest_alg'], |
|
524 |
$openssl_digest_algs |
|
525 |
))->setHelp('NOTE: It is recommended to use an algorithm stronger than SHA1 '. |
|
526 |
'when possible.'); |
|
527 |
|
|
528 |
$section->addInput(new Form_Input( |
|
529 |
'lifetime', |
|
530 |
'Lifetime (days)', |
|
531 |
'number', |
|
532 |
$pconfig['lifetime'] |
|
533 |
)); |
|
534 |
|
|
535 |
$section->addInput(new Form_Select( |
|
536 |
'dn_country', |
|
537 |
'Country Code', |
|
538 |
$pconfig['dn_country'], |
|
539 |
$dn_cc |
|
540 |
)); |
|
541 |
|
|
542 |
$section->addInput(new Form_Input( |
|
543 |
'dn_state', |
|
544 |
'State or Province', |
|
545 |
'text', |
|
546 |
$pconfig['dn_state'], |
|
547 |
['placeholder' => 'e.g. Texas'] |
|
548 |
)); |
|
549 |
|
|
550 |
$section->addInput(new Form_Input( |
|
551 |
'dn_city', |
|
552 |
'City', |
|
553 |
'text', |
|
554 |
$pconfig['dn_city'], |
|
555 |
['placeholder' => 'e.g. Austin'] |
|
556 |
)); |
|
557 |
|
|
558 |
$section->addInput(new Form_Input( |
|
559 |
'dn_organization', |
|
560 |
'Organization', |
|
561 |
'text', |
|
562 |
$pconfig['dn_organization'], |
|
563 |
['placeholder' => 'e.g. My Company Inc.'] |
|
564 |
)); |
|
565 |
|
|
566 |
$section->addInput(new Form_Input( |
|
567 |
'dn_email', |
|
568 |
'Email Address', |
|
569 |
'email', |
|
570 |
$pconfig['dn_email'], |
|
571 |
['placeholder' => 'e.g. admin@mycompany.com'] |
|
572 |
)); |
|
573 |
|
|
574 |
$section->addInput(new Form_Input( |
|
575 |
'dn_commonname', |
|
576 |
'Common Name', |
|
577 |
'text', |
|
578 |
$pconfig['dn_commonname'], |
|
579 |
['placeholder' => 'e.g. internal-ca'] |
|
580 |
)); |
|
581 |
|
|
582 |
$form->add($section); |
|
583 |
|
|
584 |
print $form; |
|
585 |
|
|
586 |
include('foot.inc'); |
Also available in: Unified diff
Converted system_camanager