Format with CodeSniffer --standard=PSR2
This commit is contained in:
11
about.php
11
about.php
@@ -1,31 +1,32 @@
|
||||
<?php
|
||||
|
||||
|
||||
include('./config.php');
|
||||
include('./include/my_functions.php');
|
||||
include('./include/common.php');
|
||||
|
||||
printHeader('about');
|
||||
|
||||
?>
|
||||
|
||||
<p>
|
||||
PHPki is an <a href=http://www.opensource.org target=_blank>Open Source</a>
|
||||
Web application for managing a <a href=<?php echo BASE_URL?>help/glossary.html#PKI target=help/glossary>
|
||||
Public Key Infrastructure</a> within a small organizations. PHPki acts as a
|
||||
mechanism for the centralized creation and management of digital certificates.
|
||||
PHPki is capable of managing certificates for multiple organizations or user
|
||||
accounts.
|
||||
accounts.</p>
|
||||
|
||||
<p>
|
||||
PHPki requires the Apache Web Server, the <href=http://www.php.net target=_blank>PHP</a> Scripting Language, and <href=http://www.openssl.org target=_blank>
|
||||
OpenSSL</a>, all of which are included with any major
|
||||
<a href=http://www.linux.org target=_blank> Linux Operating System</a>
|
||||
<a href=http://www.redhat.com target=_blank>distribution</a>.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
This software may be freely redistributed under the terms of the
|
||||
<a href=http://www.gnu.org target=_blank>GNU</a> Public
|
||||
License provided this page and all copyright notices remain completely intact.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<center><h4>Copyright: 2003, William E. Roadcap</h4>
|
||||
<form>
|
||||
@@ -36,7 +37,7 @@ readfile("./LICENSE.TXT");
|
||||
</textarea>
|
||||
</form>
|
||||
</center>
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<?php
|
||||
printFooter();
|
||||
|
@@ -10,8 +10,8 @@ $login = gpvar('login');
|
||||
$passwd = gpvar('passwd');
|
||||
$passwdv = gpvar('passwdv');
|
||||
|
||||
switch($stage) {
|
||||
case 'list_users':
|
||||
switch ($stage) {
|
||||
case 'list_users':
|
||||
printHeader('admin');
|
||||
print '<p><h3>Contents of '.htvar($config['passwd_file']).' file:</h3><pre>';
|
||||
readfile($config['passwd_file'])
|
||||
@@ -25,7 +25,7 @@ case 'list_users':
|
||||
printFooter(false);
|
||||
break;
|
||||
|
||||
case 'add_user_form';
|
||||
case 'add_user_form';
|
||||
printHeader('admin');
|
||||
?>
|
||||
<body onLoad="self.focus();document.form.login.focus()">
|
||||
@@ -42,7 +42,7 @@ case 'add_user_form';
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'add_user':
|
||||
case 'add_user':
|
||||
printHeader('admin');
|
||||
if (! $passwd || ! $passwdv || $passwd != $passwdv || strlen($passwd) < 8) {
|
||||
print "<center><h2><font color=red>Missing or invalid password or password and password verification do not match.</font></h2></center>"
|
||||
@@ -55,8 +55,7 @@ case 'add_user':
|
||||
<input type=submit name=submit value=Back>
|
||||
</form></center>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$pwdfile = escapeshellarg($config['passwd_file']);
|
||||
$login = escapeshellarg($login);
|
||||
$passwd = escapeshellarg($passwd);
|
||||
@@ -73,7 +72,7 @@ case 'add_user':
|
||||
printFooter();
|
||||
break;
|
||||
|
||||
case 'del_user_form';
|
||||
case 'del_user_form';
|
||||
printHeader('admin');
|
||||
?>
|
||||
<body onLoad="self.focus();document.form.login.focus();">
|
||||
@@ -88,7 +87,7 @@ case 'del_user_form';
|
||||
<?php
|
||||
printFooter();
|
||||
break;
|
||||
case 'del_user':
|
||||
case 'del_user':
|
||||
printHeader('admin');
|
||||
|
||||
$pwdfile = escapeshellarg($config['passwd_file']);
|
||||
@@ -105,7 +104,7 @@ case 'del_user':
|
||||
printFooter();
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
printHeader('admin');
|
||||
?>
|
||||
<br>
|
||||
|
@@ -1,3 +1,2 @@
|
||||
<?php
|
||||
header("Location: ./../index.php");
|
||||
?>
|
||||
|
30
ca/main.php
30
ca/main.php
@@ -8,29 +8,28 @@ include("../include/openssl_functions.php");
|
||||
|
||||
$stage = gpvar('stage');
|
||||
|
||||
switch($stage) {
|
||||
|
||||
case 'dl_takey':
|
||||
switch ($stage) {
|
||||
case 'dl_takey':
|
||||
upload($config['private_dir'] . '/takey.pem', $config['ca_prefix'] . 'takey.pem', 'application/octet-stream');
|
||||
break;
|
||||
|
||||
case 'dl_dhparam':
|
||||
case 'dl_dhparam':
|
||||
upload($config['private_dir'] . '/dhparam2048.pem', $config['ca_prefix'] . 'dhparam2048.pem', 'application/octet-stream');
|
||||
break;
|
||||
|
||||
case 'dl_root':
|
||||
case 'dl_root':
|
||||
upload($config['cacert_pem'], $config['ca_prefix'] . 'cacert.crt', 'application/x-x509-ca-cert');
|
||||
break;
|
||||
|
||||
case 'dl_crl':
|
||||
case 'dl_crl':
|
||||
upload($config['cacrl_der'], $config['ca_prefix'] . 'cacrl.crl', 'application/pkix-crl');
|
||||
break;
|
||||
|
||||
case 'dl_crl_pem':
|
||||
case 'dl_crl_pem':
|
||||
upload($config['cacrl_pem'], $config['ca_prefix'] . 'cacrl.crl', 'application/octet-stream');
|
||||
break;
|
||||
|
||||
case 'gen_crl':
|
||||
case 'gen_crl':
|
||||
list($ret,$errtxt) = CA_generate_crl();
|
||||
|
||||
printHeader(false);
|
||||
@@ -44,8 +43,7 @@ case 'gen_crl':
|
||||
</form>
|
||||
<?php
|
||||
print '<pre>'.CA_crl_text().'</pre>';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
?>
|
||||
<font color="#ff0000">
|
||||
<h2>There was an error updating the Certificate Revocation List.</h2></font><br>
|
||||
@@ -59,10 +57,10 @@ case 'gen_crl':
|
||||
<br>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 'display_takey':
|
||||
case 'display_takey':
|
||||
printHeader(false);
|
||||
|
||||
?>
|
||||
@@ -75,7 +73,7 @@ case 'display_takey':
|
||||
print '<pre>'.ta_key_text().'</pre>';
|
||||
break;
|
||||
|
||||
case 'display_dhparam':
|
||||
case 'display_dhparam':
|
||||
printHeader(false);
|
||||
|
||||
?>
|
||||
@@ -88,7 +86,7 @@ case 'display_dhparam':
|
||||
print '<pre>'.dhparam_text().'</pre>';
|
||||
break;
|
||||
|
||||
case 'display_root_pem':
|
||||
case 'display_root_pem':
|
||||
printHeader(false);
|
||||
|
||||
?>
|
||||
@@ -102,7 +100,7 @@ case 'display_root_pem':
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
default:
|
||||
printHeader('ca');
|
||||
?>
|
||||
<br>
|
||||
@@ -148,7 +146,7 @@ default:
|
||||
<td>This key can be used with OpenVPN as a standalone auth mechanism, or as an additional TLS authentication.</td></tr>
|
||||
<?php }
|
||||
?>
|
||||
<?php if (file_exists ($config['private_dir'] . '/dhparam2048.pem')) {
|
||||
<?php if (file_exists($config['private_dir'] . '/dhparam2048.pem')) {
|
||||
?>
|
||||
<tr><td style="text-align: center; vertical-align: middle; font-weight: bold;">
|
||||
<a href="<?php echo $PHP_SELF?>?stage=dl_dhparam">Download the Diffie-Hellman parameters</a><br><br>
|
||||
|
@@ -26,7 +26,7 @@ if ($serial && CAdb_issuer($serial) != $PHPki_user && ! in_array($PHPki_user, $P
|
||||
$stage = 'goaway';
|
||||
}
|
||||
|
||||
if ( !($show_valid.$show_revoked.$show_expired) ) {
|
||||
if (!($show_valid.$show_revoked.$show_expired)) {
|
||||
$show_valid = 'V';
|
||||
$show_revoked = 'R';
|
||||
$show_expired = 'E';
|
||||
@@ -37,7 +37,7 @@ $qstr_filter = 'search='.htvar($search) . '&' . "show_valid=$show_valid&" . "sho
|
||||
$qstr_sort = "sortfield=$sortfield&ascdec=$ascdec";
|
||||
|
||||
switch ($stage) {
|
||||
case 'goaway':
|
||||
case 'goaway':
|
||||
printHeader(false);
|
||||
?>
|
||||
|
||||
@@ -46,7 +46,7 @@ case 'goaway':
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'display':
|
||||
case 'display':
|
||||
printHeader(false);
|
||||
?>
|
||||
|
||||
@@ -62,7 +62,7 @@ case 'display':
|
||||
print '<pre>'.CA_cert_text($serial).'</pre>';
|
||||
break;
|
||||
|
||||
case 'dl-confirm':
|
||||
case 'dl-confirm':
|
||||
printHeader('ca');
|
||||
|
||||
$rec = CAdb_get_entry($serial);
|
||||
@@ -88,8 +88,10 @@ case 'dl-confirm':
|
||||
|
||||
break;
|
||||
|
||||
case 'download':
|
||||
if (strstr($submit, "Back")) $dl_type = '';
|
||||
case 'download':
|
||||
if (strstr($submit, "Back")) {
|
||||
$dl_type = '';
|
||||
}
|
||||
|
||||
$rec = CAdb_get_entry($serial);
|
||||
|
||||
@@ -98,23 +100,23 @@ case 'download':
|
||||
upload($config['pfx_dir'] . "/$serial.pfx", "$rec[common_name].p12", 'application/x-pkcs12');
|
||||
break;
|
||||
case 'PEMCERT':
|
||||
upload($config['new_certs_dir'] . "/$serial.pem", "$rec[common_name]-cert.pem",'application/pkix-cert');
|
||||
upload($config['new_certs_dir'] . "/$serial.pem", "$rec[common_name]-cert.pem", 'application/pkix-cert');
|
||||
break;
|
||||
case 'PEMKEY':
|
||||
upload($config['private_dir'] . "/$serial-key.pem", "$rec[common_name]-key.pem",'application/octet-stream');
|
||||
upload($config['private_dir'] . "/$serial-key.pem", "$rec[common_name]-key.pem", 'application/octet-stream');
|
||||
break;
|
||||
case 'PEMBUNDLE':
|
||||
upload(array($config['private_dir'] . "/$serial-key.pem",$config['new_certs_dir'] . "/$serial.pem"), $rec['common_name'] . "-Bundle.pem",'application/octet-stream');
|
||||
upload(array($config['private_dir'] . "/$serial-key.pem",$config['new_certs_dir'] . "/$serial.pem"), $rec['common_name'] . "-Bundle.pem", 'application/octet-stream');
|
||||
break;
|
||||
case 'PEMCABUNDLE':
|
||||
upload(array($config['private_dir'] . "/$serial-key.pem",$config['new_certs_dir'] . "/$serial.pem", $config['cacert_pem']), $rec['common_name'] . "-CABundle.pem",'application/octet-stream');
|
||||
upload(array($config['private_dir'] . "/$serial-key.pem",$config['new_certs_dir'] . "/$serial.pem", $config['cacert_pem']), $rec['common_name'] . "-CABundle.pem", 'application/octet-stream');
|
||||
break;
|
||||
default:
|
||||
header("Location: ${PHP_SELF}?$qstr_sort&$qstr_filter");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'revoke-form':
|
||||
case 'revoke-form':
|
||||
$rec = CAdb_get_entry($serial);
|
||||
|
||||
printHeader('ca');
|
||||
@@ -159,10 +161,11 @@ case 'revoke-form':
|
||||
|
||||
break;
|
||||
|
||||
case 'revoke':
|
||||
case 'revoke':
|
||||
$ret = true;
|
||||
if ($submit == 'Yes')
|
||||
if ($submit == 'Yes') {
|
||||
list($ret, $errtxt) = CA_revoke_cert($serial);
|
||||
}
|
||||
|
||||
if (! $ret) {
|
||||
printHeader('ca');
|
||||
@@ -180,12 +183,12 @@ case 'revoke':
|
||||
<p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
else
|
||||
} else {
|
||||
header("Location: ${PHP_SELF}?$qstr_sort&$qstr_filter");
|
||||
}
|
||||
break;
|
||||
|
||||
case 'renew-form':
|
||||
case 'renew-form':
|
||||
#
|
||||
# Get last known values submitted by this user. We only really
|
||||
# need the expiry value, but the old cert values will override
|
||||
@@ -264,7 +267,7 @@ case 'renew-form':
|
||||
print "<option value=0.25 " . ($expiry == 1 ? "selected='selected'" : "") . " >3 Months</option>\n" ;
|
||||
print "<option value=0.5 " . ($expiry == 1 ? "selected='selected'" : "") . " >6 Months</option>\n" ;
|
||||
print "<option value=1 " . ($expiry == 1 ? "selected='selected'" : "") . " >1 Year</option>\n" ;
|
||||
for ( $i = 2 ; $i <= 5 ; $i++ ) {
|
||||
for ($i = 2; $i <= 5; $i++) {
|
||||
print "<option value=$i " . ($expiry == $i ? "selected='selected'" : "") . " >$i Years</option>\n" ;
|
||||
}
|
||||
|
||||
@@ -289,7 +292,7 @@ case 'renew-form':
|
||||
printFooter();
|
||||
break;
|
||||
|
||||
case 'renew':
|
||||
case 'renew':
|
||||
$ret = true;
|
||||
if ($submit == "Submit Request") {
|
||||
list($ret, $errtxt) = CA_renew_cert($serial, $expiry, $passwd);
|
||||
@@ -312,15 +315,13 @@ case 'renew':
|
||||
<p>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
header("Location: $PHP_SELF?$qstr_sort&$qstr_filter");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
default:
|
||||
printHeader('ca');
|
||||
|
||||
?>
|
||||
@@ -351,8 +352,7 @@ default:
|
||||
if ($ascdec == 'A') {
|
||||
$arrow_gif = '../images/uparrow-blue.gif';
|
||||
$ht_ascdec = 'D';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$arrow_gif = '../images/downarrow-blue.gif';
|
||||
$ht_ascdec = 'A';
|
||||
}
|
||||
@@ -366,7 +366,7 @@ default:
|
||||
'locality'=>"Locality"
|
||||
);
|
||||
|
||||
foreach($headings as $field=>$head) {
|
||||
foreach ($headings as $field => $head) {
|
||||
print '<th><a href="'.$PHP_SELF.'?sortfield='.$field.'&ascdec=A&'.$qstr_filter.'" title="Click to sort on this column."><u>'.$head.'</u></a>';
|
||||
|
||||
if ($sortfield == $field) {
|
||||
@@ -383,8 +383,7 @@ default:
|
||||
|
||||
if (in_array($PHPki_user, $PHPki_admins)) {
|
||||
$x = "$x.*$search";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$x = "$x.*$search.*$PHPki_user|$x.*$PHPki_user.*$search";
|
||||
}
|
||||
|
||||
@@ -392,7 +391,7 @@ default:
|
||||
|
||||
$stcolor = array('Valid'=>'green','Revoked'=>'red','Expired'=>'orange');
|
||||
|
||||
foreach($db as $rec) {
|
||||
foreach ($db as $rec) {
|
||||
print '<tr style="font-size: 11px;">
|
||||
<td><font color='.$stcolor[$rec['status']].'><b>' .$rec[status].'</b></font></td>
|
||||
<td style="white-space: nowrap">'.$rec['issued'].'</td>
|
||||
|
@@ -1,78 +1,34 @@
|
||||
<html>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Certificate Authority Agreement</title>
|
||||
<title>Certificate Authority Agreement</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2 align="center">Certificate Authority Agreement</h2>
|
||||
|
||||
<h2 align=center>Certificate Authority Agreement</h2>
|
||||
<h3 align=center>Policy and Practices</h3>
|
||||
<h3 align="center">Policy and Practices</h3><br>
|
||||
<br>
|
||||
|
||||
<br><br>
|
||||
<p>This is a statement of practices by this Digital Certificate Authority.
|
||||
Your use of this Certificate Authority constitutes your and/or your agency's
|
||||
understanding and full acceptance of these practices and all associated risks.
|
||||
<strong>Please have an authorized person at your agency sign this document and fax it to 000-000-0000</strong>
|
||||
<p>This is a statement of practices by this Digital Certificate Authority. Your use of this Certificate Authority constitutes your and/or your agency's understanding and full acceptance of these practices and all associated risks. <strong>Please have an authorized person at your agency sign this document and fax it to 000-000-0000</strong></p>
|
||||
|
||||
<p>This document may not be all encompassing, and we reserve the right to modify it at any time.
|
||||
<p>This document may not be all encompassing, and we reserve the right to modify it at any time.</p>
|
||||
|
||||
<ul>
|
||||
<li> The sole role of this Certificate Authority is
|
||||
to provide and maintain a password protected software application for the easy
|
||||
and instant creation and management of standard x.509 personal digital
|
||||
certificates for e-mail encryption. We assume no responsibility for
|
||||
verifying the identity of any persons other than that of the limited number of
|
||||
authorized users of the software.
|
||||
We accept no liability for damages resulting from the use, misuse,
|
||||
or compromise of the software application or its host server.
|
||||
<ul>
|
||||
<li>The sole role of this Certificate Authority is to provide and maintain a password protected software application for the easy and instant creation and management of standard x.509 personal digital certificates for e-mail encryption. We assume no responsibility for verifying the identity of any persons other than that of the limited number of authorized users of the software. We accept no liability for damages resulting from the use, misuse, or compromise of the software application or its host server.</li>
|
||||
|
||||
<p><li>As an authorized user of the software, you are in effect <strong>THE</strong> Certificate Authority for your
|
||||
agency. As such, you are solely
|
||||
responsible for authenticating the identity of the persons for whom you obtain
|
||||
certificates. We accept no
|
||||
responsibility or liability for non-repudiation in any digital certificate
|
||||
created by this software. You agree that
|
||||
password protection to the application by authorized certificate managers,
|
||||
and personal identity management by
|
||||
those managers is sufficient to create a chain of trust for non-repudiation
|
||||
in all digital certificates created using the software.
|
||||
<li>As an authorized user of the software, you are in effect <strong>THE</strong> Certificate Authority for your agency. As such, you are solely responsible for authenticating the identity of the persons for whom you obtain certificates. We accept no responsibility or liability for non-repudiation in any digital certificate created by this software. You agree that password protection to the application by authorized certificate managers, and personal identity management by those managers is sufficient to create a chain of trust for non-repudiation in all digital certificates created using the software.</li>
|
||||
|
||||
<p><li>No more than two(2)
|
||||
users at your agency should have access to your agency's Certificate Authority
|
||||
password. We should be notified
|
||||
immediately, via e-mail, when the employment of any
|
||||
authorized user at your agency is terminated so that a new password can be
|
||||
issued.
|
||||
<li>No more than two(2) users at your agency should have access to your agency's Certificate Authority password. We should be notified immediately, via e-mail, when the employment of any authorized user at your agency is terminated so that a new password can be issued.</li>
|
||||
|
||||
<p><li>This Certificate
|
||||
Authority software application is accessed via the Internet using standard SSL
|
||||
or Secure Server encryption mechanisms.
|
||||
Although steps have been taken to protect the security and availability
|
||||
of the host server and application, its exposure to the Internet as well as any
|
||||
presently unknown security flaws could lead to potential compromise of the
|
||||
software and your certificates.
|
||||
<li>This Certificate Authority software application is accessed via the Internet using standard SSL or Secure Server encryption mechanisms. Although steps have been taken to protect the security and availability of the host server and application, its exposure to the Internet as well as any presently unknown security flaws could lead to potential compromise of the software and your certificates.</li>
|
||||
|
||||
<p><li>No promise is made as
|
||||
to the availability of the software in the event of hardware, software, or
|
||||
telecommunications failure or maintenance.<2E>
|
||||
No advanced notice will be given when the software must be temporarily
|
||||
taken off line for service.
|
||||
<li>No promise is made as to the availability of the software in the event of hardware, software, or telecommunications failure or maintenance. No advanced notice will be given when the software must be temporarily taken off line for service.</li>
|
||||
|
||||
<p><li>In order to provide
|
||||
software which can easily create "instant" certificates it is
|
||||
necessary to store all private keys on the host server. As such, all private keys are potentially exposed
|
||||
to the Internet and suffer some risk of unauthorized access. However, since all private keys <strong>ARE
|
||||
ENCRYPTED</strong> using a password provided by you, they are unlikely to be usable by
|
||||
any intruder.
|
||||
<li>In order to provide software which can easily create "instant" certificates it is necessary to store all private keys on the host server. As such, all private keys are potentially exposed to the Internet and suffer some risk of unauthorized access. However, since all private keys <strong>ARE ENCRYPTED</strong> using a password provided by you, they are unlikely to be usable by any intruder.</li>
|
||||
|
||||
<p><li>A publicly accessible
|
||||
web page is provided for interested Internet users to download the Certificate
|
||||
Authority root certificate, certificate revocation list, and search for the
|
||||
e-mail addresses and public certificates of users. So as to avoid e-mail address scraping by spammers, no static
|
||||
content with users' e-mail addresses is available.
|
||||
|
||||
</ul>
|
||||
<li>A publicly accessible web page is provided for interested Internet users to download the Certificate Authority root certificate, certificate revocation list, and search for the e-mail addresses and public certificates of users. So as to avoid e-mail address scraping by spammers, no static content with users' e-mail addresses is available.</li>
|
||||
</ul>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
@@ -7,7 +7,7 @@ include('../include/common.php') ;
|
||||
include('../include/openssl_functions.php') ;
|
||||
|
||||
# User's preferences file
|
||||
$user_cnf = $config['home_dir'] . "/config/user-".strtr($PHPki_user,'/\\','|#').'.php';
|
||||
$user_cnf = $config['home_dir'] . "/config/user-".strtr($PHPki_user, '/\\', '|#').'.php';
|
||||
|
||||
# Retrieve GET/POST values
|
||||
$form_stage = gpvar('form_stage');
|
||||
@@ -48,54 +48,76 @@ $hidden_fields = '
|
||||
|
||||
|
||||
switch ($form_stage) {
|
||||
|
||||
case 'validate':
|
||||
case 'validate':
|
||||
$er = '';
|
||||
|
||||
if (! $country) $er .= 'Missing Country<br>';
|
||||
if (! $province) $er .= 'Missing State/Province<br>';
|
||||
if (! $locality) $er .= 'Missing Locality (City/County)<br>';
|
||||
if (! $organization) $er .= 'Missing Organization (Company/Agency)<br>';
|
||||
if (! $unit) $er .= 'Missing Unit/Department<br>';
|
||||
if (! $common_name) $er .= 'Missing E-mail User\'s Full Name<br>';
|
||||
if (! $email) $er .= 'Missing E-mail Address<br>';
|
||||
if (! $country) {
|
||||
$er .= 'Missing Country<br>';
|
||||
}
|
||||
if (! $province) {
|
||||
$er .= 'Missing State/Province<br>';
|
||||
}
|
||||
if (! $locality) {
|
||||
$er .= 'Missing Locality (City/County)<br>';
|
||||
}
|
||||
if (! $organization) {
|
||||
$er .= 'Missing Organization (Company/Agency)<br>';
|
||||
}
|
||||
if (! $unit) {
|
||||
$er .= 'Missing Unit/Department<br>';
|
||||
}
|
||||
if (! $common_name) {
|
||||
$er .= 'Missing E-mail User\'s Full Name<br>';
|
||||
}
|
||||
if (! $email) {
|
||||
$er .= 'Missing E-mail Address<br>';
|
||||
}
|
||||
|
||||
if (($cert_type == 'email' || $cert_type == 'email_signing') && ! $passwd) $er .= 'Missing Certificate Password<br>';
|
||||
if (($cert_type == 'email' || $cert_type == 'email_signing') && ! $passwdv) $er .= 'Missing Certificate Password Verification "Again"<br>';
|
||||
if (($cert_type == 'email' || $cert_type == 'email_signing') && ! $passwd) {
|
||||
$er .= 'Missing Certificate Password<br>';
|
||||
}
|
||||
if (($cert_type == 'email' || $cert_type == 'email_signing') && ! $passwdv) {
|
||||
$er .= 'Missing Certificate Password Verification "Again"<br>';
|
||||
}
|
||||
|
||||
if ( $passwd && strlen($passwd) < 8 )
|
||||
if ($passwd && strlen($passwd) < 8) {
|
||||
$er .= 'Certificate password is too short.<br>';
|
||||
}
|
||||
|
||||
if ( $passwd and $passwd != $passwdv )
|
||||
if ($passwd and $passwd != $passwdv) {
|
||||
$er .= 'Password and password verification do not match.<br>';
|
||||
}
|
||||
|
||||
//if ( ! is_alnum($passwd) or ! is_alnum($passwdv) )
|
||||
// $er .= 'Password contains invalid characters.<br>';
|
||||
|
||||
if ( $email && ! is_email($email) )
|
||||
if ($email && ! is_email($email)) {
|
||||
$er .= 'E-mail address ('. htvar($email) . ') may be invalid.<br>';
|
||||
}
|
||||
|
||||
$ip_ar=explode("\n", $ip_addr);
|
||||
foreach ($ip_ar as $value){
|
||||
if ( $value && ! is_ip($value) )
|
||||
foreach ($ip_ar as $value) {
|
||||
if ($value && ! is_ip($value)) {
|
||||
$er .= 'IP address ('. htvar($value) . ') may be invalid.<br>';
|
||||
}
|
||||
}
|
||||
|
||||
$dns_n=explode("\n", $dns_names);
|
||||
foreach ($dns_n as $value){
|
||||
if ( $value && ! is_fqdn(trim($value)) )
|
||||
foreach ($dns_n as $value) {
|
||||
if ($value && ! is_fqdn(trim($value))) {
|
||||
$er .= 'DNS Name ('. htvar($value) . ') may be invalid.<br>';
|
||||
}
|
||||
}
|
||||
|
||||
if ( $er )
|
||||
if ($er) {
|
||||
$er = '<h2>ERROR(S) IN FORM:</h2><h4><blockquote>' . $er . '</blockquote></h4>';
|
||||
}
|
||||
|
||||
if ($email && ($serial = CAdb_in($email,$common_name))) {
|
||||
if ($email && ($serial = CAdb_in($email, $common_name))) {
|
||||
$er = '';
|
||||
$certtext = CA_cert_text($serial);
|
||||
$er .= '<h2>A valid certificate already exists for ' . htvar("$common_name <$email>") . '</h2>';
|
||||
$er .= '</font><blockquote><pre> ' . htvar($certtext) . ' </pre></blockquote>';
|
||||
|
||||
}
|
||||
|
||||
if ($er) {
|
||||
@@ -115,7 +137,7 @@ case 'validate':
|
||||
break;
|
||||
}
|
||||
|
||||
case 'confirm':
|
||||
case 'confirm':
|
||||
printHeader();
|
||||
|
||||
?>
|
||||
@@ -134,7 +156,7 @@ case 'confirm':
|
||||
Key Size<br>
|
||||
Certificate Use<br>
|
||||
<?php
|
||||
if ($cert_type == 'server' ) {
|
||||
if ($cert_type == 'server') {
|
||||
print 'DNS Alt Names<br>';
|
||||
print 'IP Addresses<br>';
|
||||
}
|
||||
@@ -177,7 +199,6 @@ case 'confirm':
|
||||
break;
|
||||
case 'time_stamping':
|
||||
print 'Time Stamping' . '<br>';
|
||||
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
@@ -197,7 +218,7 @@ case 'confirm':
|
||||
printFooter();
|
||||
|
||||
# Save user's defaults
|
||||
$fp = fopen($user_cnf,'w');
|
||||
$fp = fopen($user_cnf, 'w');
|
||||
$x = '<?php
|
||||
$country = \''.addslashes($country).'\';
|
||||
$locality = \''.addslashes($locality).'\';
|
||||
@@ -207,14 +228,14 @@ case 'confirm':
|
||||
$expiry = \''.addslashes($expiry).'\';
|
||||
$keysize = \''.addslashes($keysize).'\';
|
||||
?>';
|
||||
fwrite($fp,$x);
|
||||
fwrite($fp, $x);
|
||||
fclose($fp);
|
||||
|
||||
break;
|
||||
|
||||
case 'final':
|
||||
case 'final':
|
||||
if ($submit == "Yes Create and Download" || $submit == "Yes. Just Create") {
|
||||
if (! $serial = CAdb_in($email,$common_name)) {
|
||||
if (! $serial = CAdb_in($email, $common_name)) {
|
||||
list($ret,$errtxt) = CA_create_cert($cert_type, $country, $province, $locality, $organization, $unit, $common_name, $email, $expiry, $passwd, $keysize, $dns_names, $ip_addr);
|
||||
|
||||
if (! $ret) {
|
||||
@@ -235,18 +256,17 @@ case 'final':
|
||||
<?php
|
||||
printFooter();
|
||||
break;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$serial = $errtxt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($submit == "Yes Create and Download") {
|
||||
switch($cert_type) {
|
||||
switch ($cert_type) {
|
||||
case 'server':
|
||||
# upload(array("$config[private_dir]/$serial-key.pem","$config[new_certs_dir]/$serial.pem",$config['cacert_pem']), "$common_name ($email).pem",'application/pkix-cert');
|
||||
upload(array($config['private_dir'] . "/$serial-key.pem",$config['new_certs_dir'] . "/$serial.pem",$config['cacert_pem']), $rec['common_name'] . "-Bundle.pem",'application/pkix-cert');
|
||||
# upload(array("$config[private_dir]/$serial-key.pem","$config[new_certs_dir]/$serial.pem",$config['cacert_pem']), "$common_name ($email).pem",'application/pkix-cert');
|
||||
upload(array($config['private_dir'] . "/$serial-key.pem",$config['new_certs_dir'] . "/$serial.pem",$config['cacert_pem']), $rec['common_name'] . "-Bundle.pem", 'application/pkix-cert');
|
||||
break;
|
||||
case 'email':
|
||||
case 'email_signing':
|
||||
@@ -254,7 +274,7 @@ case 'final':
|
||||
case 'vpn_client_server':
|
||||
case 'vpn_client':
|
||||
case 'vpn_server':
|
||||
# upload("$config[pfx_dir]/$serial.pfx", "$common_name ($email).p12", 'application/x-pkcs12');
|
||||
# upload("$config[pfx_dir]/$serial.pfx", "$common_name ($email).p12", 'application/x-pkcs12');
|
||||
upload($config['pfx_dir'] . "/$serial.pfx", $rec['common_name'] . ".p12", 'application/x-pkcs12');
|
||||
break;
|
||||
}
|
||||
@@ -264,28 +284,52 @@ case 'final':
|
||||
break;
|
||||
}
|
||||
|
||||
# Clear common_name fields
|
||||
$common_name = '';
|
||||
# Clear common_name fields
|
||||
$common_name = '';
|
||||
|
||||
// We could add 'return to index or create another certificate'
|
||||
// We could add 'return to index or create another certificate'
|
||||
|
||||
default:
|
||||
default:
|
||||
#
|
||||
# Default fields to reasonable values if necessary.
|
||||
#
|
||||
if (! $submit and file_exists($user_cnf)) include($user_cnf);
|
||||
if (! $submit and file_exists($user_cnf)) {
|
||||
include($user_cnf);
|
||||
}
|
||||
|
||||
if (! $country) $country = $config['country'];
|
||||
if (! $province) $province = $config['province'];
|
||||
if (! $locality) $locality = "";
|
||||
if (! $organization) $organization = "";
|
||||
if (! $unit) $unit = "";
|
||||
if (! $email) $email = "";
|
||||
if (! $expiry) $expiry = 1;
|
||||
if (! $keysize) $keysize = 2048;
|
||||
if (! $cert_type) $cert_type = 'email';
|
||||
if (! $dns_names) $dns_names = "";
|
||||
if (! $ip_addr) $ip_addr = "";
|
||||
if (! $country) {
|
||||
$country = $config['country'];
|
||||
}
|
||||
if (! $province) {
|
||||
$province = $config['province'];
|
||||
}
|
||||
if (! $locality) {
|
||||
$locality = "";
|
||||
}
|
||||
if (! $organization) {
|
||||
$organization = "";
|
||||
}
|
||||
if (! $unit) {
|
||||
$unit = "";
|
||||
}
|
||||
if (! $email) {
|
||||
$email = "";
|
||||
}
|
||||
if (! $expiry) {
|
||||
$expiry = 1;
|
||||
}
|
||||
if (! $keysize) {
|
||||
$keysize = 2048;
|
||||
}
|
||||
if (! $cert_type) {
|
||||
$cert_type = 'email';
|
||||
}
|
||||
if (! $dns_names) {
|
||||
$dns_names = "";
|
||||
}
|
||||
if (! $ip_addr) {
|
||||
$ip_addr = "";
|
||||
}
|
||||
|
||||
printHeader();
|
||||
?>
|
||||
@@ -341,7 +385,7 @@ default:
|
||||
print "<option value=0.25 " . ($expiry == 1 ? "selected='selected'" : "") . " >3 Months</option>\n" ;
|
||||
print "<option value=0.5 " . ($expiry == 1 ? "selected='selected'" : "") . " >6 Months</option>\n" ;
|
||||
print "<option value=1 " . ($expiry == 1 ? "selected='selected'" : "") . " >1 Year</option>\n" ;
|
||||
for ( $i = 2 ; $i <= 5 ; $i++ ) {
|
||||
for ($i = 2; $i <= 5; $i++) {
|
||||
print "<option value=$i " . ($expiry == $i ? "selected='selected'" : "") . " >$i Years</option>\n" ;
|
||||
}
|
||||
|
||||
@@ -354,7 +398,7 @@ default:
|
||||
<td>Key Size<font color=red size=3>*</font> </td>
|
||||
<td><select name=keysize>
|
||||
<?php
|
||||
for ( $i = 512 ; $i <= 4096 ; $i+= 512 ) {
|
||||
for ($i = 512; $i <= 4096; $i+= 512) {
|
||||
print "<option value=$i " . ($keysize == $i ? "selected='selected'" : "") . ">$i bits</option>\n" ;
|
||||
}
|
||||
?>
|
||||
|
@@ -1,3 +1,2 @@
|
||||
<?php
|
||||
define("PHPKI_VERSION", "0.84");
|
||||
?>
|
||||
|
@@ -10,5 +10,3 @@ include('../html/include/common.php') ;
|
||||
include('../html/include/openssl_functions.php') ;
|
||||
|
||||
CA_generate_crl();
|
||||
|
||||
?>
|
||||
|
11
help.php
11
help.php
@@ -5,11 +5,12 @@ include('./include/common.php');
|
||||
|
||||
printHeader(about);
|
||||
?>
|
||||
<center><h1>PHPki HELP FILES</h1>
|
||||
<a href=<?php echo BASE_URL?>help/PKI_basics.html><h3>PKI and E-mail Encryption - A Brief Explanation</h3></a>
|
||||
<a href=<?php echo BASE_URL?>help/cacert_install_ie.html><h3>Installing Our Root Certificate For Use With Outlook and Outlook Express</h3></a>
|
||||
<p><a href=<?php echo BASE_URL?>help/usercert_install_ie.html><h3>Installing Your Personal E-mail Certificate For Use With Outlook and Outlook Express</h3></a>
|
||||
<p><a href=<?php echo BASE_URL?>help/glossary.html><h3>Glossary</h3></a>
|
||||
<center>
|
||||
<h1>PHPki HELP FILES</h1>
|
||||
<p><a href="<?php echo BASE_URL?>"help/PKI_basics.html><h3>PKI and E-mail Encryption - A Brief Explanation</h3></a></p>
|
||||
<p><a href="<?php echo BASE_URL?>"help/cacert_install_ie.html><h3>Installing Our Root Certificate For Use With Outlook and Outlook Express</h3></a></p>
|
||||
<p><a href="<?php echo BASE_URL?>"help/usercert_install_ie.html><h3>Installing Your Personal E-mail Certificate For Use With Outlook and Outlook Express</h3></a></p>
|
||||
<p><a href="<?php echo BASE_URL?>"help/glossary.html><h3>Glossary</h3></a></p>
|
||||
</center>
|
||||
<?php
|
||||
printFooter();
|
||||
|
@@ -1,64 +1,28 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
<title>PKI and E-mail Encryption - A Brief Explanation</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
|
||||
<title>PKI and E-mail Encryption - A Brief Explanation</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<center><h1>PKI and E-mail Encryption - A Brief Explanation</h2></center>
|
||||
<center>
|
||||
<h1>PKI and E-mail Encryption - A Brief Explanation</h1>
|
||||
</center>
|
||||
|
||||
PKI stands for <cite>Public Key Infrastructure</cite>. PKI is Information
|
||||
Technology infrastructure that enables users of a basically unsecure public
|
||||
network (such as the Internet) to securely and privately exchange data through
|
||||
the use of a <a href=glossary.html#KEYS target=glossary>public and a private
|
||||
cryptographic key pair</a> that is obtained and shared through a
|
||||
<a href=glossary.html#CA target=glossary>trusted Authority</a>.
|
||||
<p>PKI stands for <cite>Public Key Infrastructure</cite>. PKI is Information Technology infrastructure that enables users of a basically unsecure public network (such as the Internet) to securely and privately exchange data through the use of a <a href="glossary.html#KEYS" target="glossary">public and a private cryptographic key pair</a> that is obtained and shared through a <a href="glossary.html#CA" target="glossary">trusted Authority</a>.</p>
|
||||
|
||||
<p>
|
||||
Public and private keys are like two halves of a single key. PKI encryption
|
||||
algorithms are designed such that a public key is used to encrypt or
|
||||
"lock" a message, and only the complementary private key can "unlock" that
|
||||
message.
|
||||
Think of a bank vault or safe that can only be unlocked by two individuals
|
||||
using two different but complementary keys. Neither of those keys can be used
|
||||
by itself to unlock the vault.
|
||||
<p>Public and private keys are like two halves of a single key. PKI encryption algorithms are designed such that a public key is used to encrypt or "lock" a message, and only the complementary private key can "unlock" that message. Think of a bank vault or safe that can only be unlocked by two individuals using two different but complementary keys. Neither of those keys can be used by itself to unlock the vault.</p>
|
||||
|
||||
<p>
|
||||
In practice, individuals wishing to exchange encrypted e-mail
|
||||
will agree to mutually trust one or more <a href=glossary.html#CA target=glossary>
|
||||
Certificate Authorities(CA)</a> by downloading and installing each trusted Authority's
|
||||
<a href=glossary.html#ROOT-CERT target=glossary>root certificate</a> on their computers.
|
||||
They will each obtain their own personal
|
||||
<a href=glossary.html#CERTIFICATE target=glossary>digital certificate</a>
|
||||
from a trusted Certificate Authority, and install them on their
|
||||
respective computers.
|
||||
Because they mutually trust the Certificate Authorities, they trust each other's
|
||||
digital certificates. More specifically, they trust the
|
||||
<a href=glossary.html#KEYS target=glossary>public keys</a> contained within
|
||||
their personal digital certificates which have been
|
||||
<a href=glossary.html#SIGNATURE target=glossary>digitally signed</a> by a
|
||||
trusted Certificate Authority.
|
||||
They will then exchange their trusted public keys by sending each other
|
||||
digitally signed e-mail messages. Once each party has the other's public key,
|
||||
they may exchange trusted and encrypted messsages.
|
||||
<p>In practice, individuals wishing to exchange encrypted e-mail will agree to mutually trust one or more <a href="glossary.html#CA" target="glossary">Certificate Authorities(CA)</a> by downloading and installing each trusted Authority's <a href="glossary.html#ROOT-CERT" target="glossary">root certificate</a> on their computers. They will each obtain their own personal <a href="glossary.html#CERTIFICATE" target="glossary">digital certificate</a> from a trusted Certificate Authority, and install them on their respective computers. Because they mutually trust the Certificate Authorities, they trust each other's digital certificates. More specifically, they trust the <a href="glossary.html#KEYS" target="glossary">public keys</a> contained within their personal digital certificates which have been <a href="glossary.html#SIGNATURE" target="glossary">digitally signed</a> by a trusted Certificate Authority. They will then exchange their trusted public keys by sending each other digitally
|
||||
signed e-mail messages. Once each party has the other's public key, they may exchange trusted and encrypted messsages.</p>
|
||||
|
||||
<p>
|
||||
Public key exchange and encryption is like exchanging notarized documents.
|
||||
One trusts a notarized document because a trusted third party, the Notary
|
||||
Public, has signed it. The Certificate Authority is the Notary Public, and
|
||||
the public keys are the documents.
|
||||
<p>Public key exchange and encryption is like exchanging notarized documents. One trusts a notarized document because a trusted third party, the Notary Public, has signed it. The Certificate Authority is the Notary Public, and the public keys are the documents.</p>
|
||||
|
||||
<p>
|
||||
Remember, having a personal digital certificate alone does <strong>not</strong>
|
||||
give one the ability to send encrypted e-mail to others, but only allows the
|
||||
<strong>receipt</strong> of encrypted e-mail. PKI is a cooperative encryption
|
||||
standard. Both parties who are exchanging encrypted messages must have
|
||||
personal digital certificates, they must trust the Certificate Authority
|
||||
which issued the other persons certificate, and they must exchange
|
||||
public keys with each other, as described above.
|
||||
|
||||
<p>
|
||||
The process of installing certificates and exchanging public keys is dependent
|
||||
upon the e-mail application one uses, and is beyond the scope of this document.
|
||||
<p>Remember, having a personal digital certificate alone does <strong>not</strong> give one the ability to send encrypted e-mail to others, but only allows the <strong>receipt</strong> of encrypted e-mail. PKI is a cooperative encryption standard. Both parties who are exchanging encrypted messages must have personal digital certificates, they must trust the Certificate Authority which issued the other persons certificate, and they must exchange public keys with each other, as described above.</p>
|
||||
|
||||
<p>The process of installing certificates and exchanging public keys is dependent upon the e-mail application one uses, and is beyond the scope of this document.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,29 +1,47 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Root Certificate Installation for Outlook & Outlook Express</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
<title>Root Certificate Installation for Outlook & Outlook Express</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
</head>
|
||||
<body>
|
||||
<center><h1>Root Certificate Installation for Outlook & Outlook Express</h1>
|
||||
<h2>A Step-by-Step Guide</h2></center><br>
|
||||
<h4>
|
||||
<p><img src=../images/right-click-install-cacert.jpg>
|
||||
<p>Open the folder which holds the certificates you have downloaded.<br>
|
||||
Right-click on the certificate you wish to install, and select
|
||||
<cite>Install Certificate</cite> from the context menu.
|
||||
<p><br><img src=../images/cert-wizard1-welcome.jpg >
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Certificate Wizard</cite>
|
||||
welcome window.
|
||||
<p><br><img src=../images/cert-wizard4-select-store.jpg>
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Select a Certificate Store</cite> window.
|
||||
<p><br><img src=../images/cert-wizard5-root-final.jpg>
|
||||
<p>Click the <cite>Finish</cite> button in the <cite>Complete the Certificate..</cite> window.
|
||||
<p><br><img src=../images/confirm-install-cacert.jpg>
|
||||
<p>You may be asked to confirm the root certificate installation. Click the <cite>Yes</cite> button if a window like this appears.
|
||||
<p><br><img src=../images/import-successful.jpg>
|
||||
<p>Windows confirms the root certificate was successfully imported.<br>
|
||||
You may now <a href=usercert_install_ie.html>install your personal e-mail certificate</a>.
|
||||
|
||||
</h4>
|
||||
<body>
|
||||
<center>
|
||||
<h1>Root Certificate Installation for Outlook & Outlook Express</h1>
|
||||
|
||||
<h2>A Step-by-Step Guide</h2>
|
||||
</center><br>
|
||||
|
||||
<p><img src="../images/right-click-install-cacert.jpg"></p>
|
||||
|
||||
<p>Open the folder which holds the certificates you have downloaded.<br>
|
||||
Right-click on the certificate you wish to install, and select <cite>Install Certificate</cite> from the context menu.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard1-welcome.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Certificate Wizard</cite> welcome window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard4-select-store.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Select a Certificate Store</cite> window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard5-root-final.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Finish</cite> button in the <cite>Complete the Certificate..</cite> window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/confirm-install-cacert.jpg"></p>
|
||||
|
||||
<p>You may be asked to confirm the root certificate installation. Click the <cite>Yes</cite> button if a window like this appears.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/import-successful.jpg"></p>
|
||||
|
||||
<p>Windows confirms the root certificate was successfully imported.<br>
|
||||
You may now <a href="usercert_install_ie.html">install your personal e-mail certificate</a>.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,144 +1,169 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>PHPki Glossary</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
<title>PHPki Glossary</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<a name="TOP" id="TOP"></a> <a name="PKI" id="PKI"></a>
|
||||
|
||||
<a name=TOP></a>
|
||||
<a name=PKI></a><p>
|
||||
<table>
|
||||
<th><h2>PUBLIC KEY INFRASTRUCTURE</h2></th>
|
||||
<tr><td>
|
||||
PKI stands for <cite>Public Key Infrastructure</cite>. PKI is IT infrastructure that enables users of a basically unsecure public network (such as the Internet) to securely and privately exchange data through the use of a public and a private <a href=#KEYS>cryptographic key pair</a> that is obtained and shared through a trusted authority.
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>PUBLIC KEY INFRASTRUCTURE</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
PKI is not only software or hardware. It is an infrastructure. So, PKI is a combination of products, services, facilities, policies, procedures, agreements, and people. All of these elements work together to provide for secure interactions on the Internet and other open networks. PKI is not a single monolithic entity, but a distributed system. The component elements may include multiple organization-specific public key infrastructures that are interoperable and interconnected.
|
||||
</td></tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td>PKI stands for <cite>Public Key Infrastructure</cite>. PKI is IT infrastructure that enables users of a basically unsecure public network (such as the Internet) to securely and privately exchange data through the use of a public and a private <a href="#KEYS">cryptographic key pair</a> that is obtained and shared through a trusted authority. PKI is not only software or hardware. It is an infrastructure. So, PKI is a combination of products, services, facilities, policies, procedures, agreements, and people. All of these elements work together to provide for secure interactions on the Internet and other open networks. PKI is not a single monolithic entity, but a distributed system. The component elements may include multiple organization-specific public key infrastructures that are interoperable and interconnected.</td>
|
||||
</tr>
|
||||
</table><a name="CERTIFICATE" id="CERTIFICATE"></a>
|
||||
|
||||
<a name=CERTIFICATE></a><p>
|
||||
<table>
|
||||
<th><h2>DIGITAL CERTIFICATE</h2></th>
|
||||
<tr><td>
|
||||
<p>
|
||||
An attachment to an electronic message used for security purposes. The most common use of a digital certificate is to verify that a user sending a message is who he or she claims to be, and to provide the receiver with the means to encode a reply.
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>DIGITAL CERTIFICATE</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<p>An individual wishing to send an encrypted message applies for a digital certificate from a <a href=#CA>Certificate Authority (CA)</a>. The CA issues an encrypted digital certificate containing the applicant's <a href=#KEYS>public key</a> and a variety of other identification information. The CA makes its own public key readily available through print publicity or perhaps on the Internet.
|
||||
<tr>
|
||||
<td>
|
||||
<p>An attachment to an electronic message used for security purposes. The most common use of a digital certificate is to verify that a user sending a message is who he or she claims to be, and to provide the receiver with the means to encode a reply.</p>
|
||||
|
||||
<p>The recipient of an encrypted message uses the CA's public key to decode the digital certificate attached to the message, verifies it as issued by the CA and then obtains the sender's public key and identification information held within the certificate. With this information, the recipient can send an encrypted reply.
|
||||
<p>An individual wishing to send an encrypted message applies for a digital certificate from a <a href="#CA">Certificate Authority (CA)</a>. The CA issues an encrypted digital certificate containing the applicant's <a href="#KEYS">public key</a> and a variety of other identification information. The CA makes its own public key readily available through print publicity or perhaps on the Internet.</p>
|
||||
|
||||
<p>The most widely used standard for digital certificates is X.509.
|
||||
</td></tr>
|
||||
</table>
|
||||
<p>The recipient of an encrypted message uses the CA's public key to decode the digital certificate attached to the message, verifies it as issued by the CA and then obtains the sender's public key and identification information held within the certificate. With this information, the recipient can send an encrypted reply.</p>
|
||||
|
||||
<a name=CA></a><p>
|
||||
<table>
|
||||
<th><h2>CERTIFICATE AUTHORITY</h2></th>
|
||||
<tr><td>
|
||||
A trusted third-party organization or company that issues digital certificates used to create digital signatures and <a href=#KEYS>public-private key pairs</a>. The role of the CA in this process is to guarantee that the individual granted the unique certificate is, in fact, who he or she claims to be. Usually, this means that the CA has an arrangement with a financial institution, such as a credit card company, which provides it with information to confirm an individual's claimed identity. CAs are a critical component in data security and electronic commerce because they guarantee that the two parties exchanging information are really who they claim to be.
|
||||
</td></tr>
|
||||
</table>
|
||||
<p>The most widely used standard for digital certificates is X.509.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table><a name="CA" id="CA"></a>
|
||||
|
||||
<a name=KEYS></a><p>
|
||||
<table>
|
||||
<th><h2>PUBLIC KEY ENCRYPTION</h2></th>
|
||||
<tr><td>
|
||||
A cryptographic system that uses two keys -- a public key known to everyone and a private or secret key known only to the recipient of the message. When John wants to send a secure message to Jane, he uses Jane's public key to encrypt the message. Jane then uses her private key to decrypt it.
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>CERTIFICATE AUTHORITY</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<p>An important element to the public key system is that the public and private keys are related in such a way that only the public key can be used to encrypt messages and only the corresponding private key can be used to decrypt them. Moreover, it is virtually impossible to deduce the private key if you know the public key.
|
||||
</td></tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td>A trusted third-party organization or company that issues digital certificates used to create digital signatures and <a href="#KEYS">public-private key pairs</a>. The role of the CA in this process is to guarantee that the individual granted the unique certificate is, in fact, who he or she claims to be. Usually, this means that the CA has an arrangement with a financial institution, such as a credit card company, which provides it with information to confirm an individual's claimed identity. CAs are a critical component in data security and electronic commerce because they guarantee that the two parties exchanging information are really who they claim to be.</td>
|
||||
</tr>
|
||||
</table><a name="KEYS" id="KEYS"></a>
|
||||
|
||||
<a name=SMIME></a><p>
|
||||
<table>
|
||||
<th><h2>S/MIME</h2></th>
|
||||
<tr><td>
|
||||
S/MIME (Secure Multi-Purpose Internet Mail Extensions) is a secure method of sending e-mail that uses the <a href=#RSA>RSA</a> encryption system. S/MIME is included in the latest versions of the Web browsers from Microsoft and Netscape and has also been endorsed by other vendors that make messaging products. RSA has proposed S/MIME as a standard to the Internet Engineering Task Force (IETF).
|
||||
</td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>PUBLIC KEY ENCRYPTION</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<a name=RSA></a><p>
|
||||
<table>
|
||||
<th><h2>RSA</h2></th>
|
||||
<tr><td>
|
||||
RSA is an Internet encryption and authentication system that uses an algorithm developed in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman. The RSA algorithm is the most commonly used encryption and authentication algorithm and is included as part of the Web browsers from Microsoft and Netscape. It's also part of Lotus Notes, Intuit's Quicken, and many other products. The encryption system was owned by RSA Security, but a recent patent expiration placed it into the public domain. The technologies are part of existing or proposed Web, Internet, and computing standards.
|
||||
</td></tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td>
|
||||
<p>A cryptographic system that uses two keys -- a public key known to everyone and a private or secret key known only to the recipient of the message. When John wants to send a secure message to Jane, he uses Jane's public key to encrypt the message. Jane then uses her private key to decrypt it.</p>
|
||||
|
||||
<a name=ROOT-CERT></a><p>
|
||||
<table>
|
||||
<th><h2>ROOT CERTIFICATE</h2></th>
|
||||
<tr><td>
|
||||
A root certificate is like a MASTER
|
||||
<a href=#CERTIFICATE>digital certificate</a>.
|
||||
You must install a <a href=#CA>certificate authority's</a> root certificate
|
||||
before you can trust other certificates issued by that same certificate
|
||||
authority. Root certificates are used to "sign" other certificates.
|
||||
A signature by a root certificate is somewhat analogous to "notarizing" a
|
||||
document in the physical world. When you install a root certificate on your
|
||||
computer, you are saying you "trust" that certification authority and all
|
||||
certificates it signs.
|
||||
</td></tr>
|
||||
</table>
|
||||
<p>An important element to the public key system is that the public and private keys are related in such a way that only the public key can be used to encrypt messages and only the corresponding private key can be used to decrypt them. Moreover, it is virtually impossible to deduce the private key if you know the public key.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table><a name="SMIME" id="SMIME"></a>
|
||||
|
||||
<a name=SIGNATURE></a><p>
|
||||
<table>
|
||||
<th><h2>DIGITAL SIGNATURE</h2></th>
|
||||
<tr><td>
|
||||
A digital code that can be attached to an electronically transmitted message
|
||||
that uniquely identifies the sender. Like a written signature, the purpose of
|
||||
a digital signature is to guarantee that the individual sending the message
|
||||
really is who he or she claims to be. Digital certificates inherently provide
|
||||
digital signature capability to most S/MIME enable e-mail clients. Digitally
|
||||
signing an e-mail usually provides the recipient the with the sender's public
|
||||
key, so the recipient may then send encrypted e-mail back to the sender.
|
||||
</td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>S/MIME</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<a name=X509></a><p>
|
||||
<table>
|
||||
<th><h2>X.509</h2></th>
|
||||
<tr><td>
|
||||
The most widely used standard for defining digital certificates. X.509 is
|
||||
actually an ITU Recommendation, which means that has not yet been officially
|
||||
defined or approved. As a result, companies have implemented the standard in
|
||||
different ways. For example, both Netscape and Microsoft use X.509 certificates
|
||||
to implement SSL in their web servers and browsers. But an X.509 certificate
|
||||
generated by Netscape may not be readable by Microsoft products, and vice
|
||||
versa.
|
||||
</td></tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td>S/MIME (Secure Multi-Purpose Internet Mail Extensions) is a secure method of sending e-mail that uses the <a href="#RSA">RSA</a> encryption system. S/MIME is included in the latest versions of the Web browsers from Microsoft and Netscape and has also been endorsed by other vendors that make messaging products. RSA has proposed S/MIME as a standard to the Internet Engineering Task Force (IETF).</td>
|
||||
</tr>
|
||||
</table><a name="RSA" id="RSA"></a>
|
||||
|
||||
<a name=PEM></a><p>
|
||||
<table>
|
||||
<th><h2>PEM</h2></th>
|
||||
<tr><td>
|
||||
PEM is a widely used standard for storing digital certificates.
|
||||
A PEM encoded file can contain all of private keys, public keys, and
|
||||
<a href=#X509>(x.509)</a> certificates. It is the default format for OpenSSL.
|
||||
It stores data in Base64 encoded format, surrounded by ascii headers, so it is
|
||||
suitable for text mode transfers between systems. PEM files usually end with
|
||||
a <cite>.PEM</cite> extension.
|
||||
</td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>RSA</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<a name=DER></a><p>
|
||||
<table>
|
||||
<th><h2>DER</h2></th>
|
||||
<tr><td>
|
||||
DER is a widely used standard for storing digital certificates. A DER encoded
|
||||
file can contain all of private keys, public keys, and <a href=#X509>(x.509)</a>
|
||||
certificates. DER is a binary encoded headerless format. DER files usually
|
||||
end with a <cite>.CRT</cite> or <cite>.CER</cite> extension.
|
||||
</td></tr>
|
||||
</table>
|
||||
<tr>
|
||||
<td>RSA is an Internet encryption and authentication system that uses an algorithm developed in 1977 by Ron Rivest, Adi Shamir, and Leonard Adleman. The RSA algorithm is the most commonly used encryption and authentication algorithm and is included as part of the Web browsers from Microsoft and Netscape. It's also part of Lotus Notes, Intuit's Quicken, and many other products. The encryption system was owned by RSA Security, but a recent patent expiration placed it into the public domain. The technologies are part of existing or proposed Web, Internet, and computing standards.</td>
|
||||
</tr>
|
||||
</table><a name="ROOT-CERT" id="ROOT-CERT"></a>
|
||||
|
||||
<a name=PKCS12></a><p>
|
||||
<table>
|
||||
<th><h2>PKCS #12</h2></th>
|
||||
<tr><td>
|
||||
PKCS #12 (a.k.a. Personal Information Exchange Standard) is a standard for storing private keys and certificates securely (well sort of). It is used in (among other things) Netscape and Microsoft Internet Explorer with their import and export options. PKCS12 files usually end with a <cite>.PFX</cite> extension.
|
||||
</td></tr>
|
||||
</table>
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>ROOT CERTIFICATE</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<br><br></body></html>
|
||||
<tr>
|
||||
<td>A root certificate is like a MASTER <a href="#CERTIFICATE">digital certificate</a>. You must install a <a href="#CA">certificate authority's</a> root certificate before you can trust other certificates issued by that same certificate authority. Root certificates are used to "sign" other certificates. A signature by a root certificate is somewhat analogous to "notarizing" a document in the physical world. When you install a root certificate on your computer, you are saying you "trust" that certification authority and all certificates it signs.</td>
|
||||
</tr>
|
||||
</table><a name="SIGNATURE" id="SIGNATURE"></a>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>DIGITAL SIGNATURE</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>A digital code that can be attached to an electronically transmitted message that uniquely identifies the sender. Like a written signature, the purpose of a digital signature is to guarantee that the individual sending the message really is who he or she claims to be. Digital certificates inherently provide digital signature capability to most S/MIME enable e-mail clients. Digitally signing an e-mail usually provides the recipient the with the sender's public key, so the recipient may then send encrypted e-mail back to the sender.</td>
|
||||
</tr>
|
||||
</table><a name="X509" id="X509"></a>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>X.509</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>The most widely used standard for defining digital certificates. X.509 is actually an ITU Recommendation, which means that has not yet been officially defined or approved. As a result, companies have implemented the standard in different ways. For example, both Netscape and Microsoft use X.509 certificates to implement SSL in their web servers and browsers. But an X.509 certificate generated by Netscape may not be readable by Microsoft products, and vice versa.</td>
|
||||
</tr>
|
||||
</table><a name="PEM" id="PEM"></a>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>PEM</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>PEM is a widely used standard for storing digital certificates. A PEM encoded file can contain all of private keys, public keys, and <a href="#X509">(x.509)</a> certificates. It is the default format for OpenSSL. It stores data in Base64 encoded format, surrounded by ascii headers, so it is suitable for text mode transfers between systems. PEM files usually end with a <cite>.PEM</cite> extension.</td>
|
||||
</tr>
|
||||
</table><a name="DER" id="DER"></a>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>DER</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>DER is a widely used standard for storing digital certificates. A DER encoded file can contain all of private keys, public keys, and <a href="#X509">(x.509)</a> certificates. DER is a binary encoded headerless format. DER files usually end with a <cite>.CRT</cite> or <cite>.CER</cite> extension.</td>
|
||||
</tr>
|
||||
</table><a name="PKCS12" id="PKCS12"></a>
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>
|
||||
<h2>PKCS #12</h2>
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td>PKCS #12 (a.k.a. Personal Information Exchange Standard) is a standard for storing private keys and certificates securely (well sort of). It is used in (among other things) Netscape and Microsoft Internet Explorer with their import and export options. PKCS12 files usually end with a <cite>.PFX</cite> extension.</td>
|
||||
</tr>
|
||||
</table><br>
|
||||
<br>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -1,40 +1,51 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Personal E-mail Certificate Installation for Outlook & Outlook Express</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
<title>Personal E-mail Certificate Installation for Outlook & Outlook Express</title>
|
||||
<link rel='stylesheet' type='text/css' href='../css/style.css'>
|
||||
</head>
|
||||
<body>
|
||||
<center><h1>Personal E-mail Certificate Installation for Outlook & Outlook Express</h1>
|
||||
<h2>A Step-by-Step Guide</h2></center><br>
|
||||
<h4>
|
||||
<p><img src=../images/right-click-install-usercert.jpg>
|
||||
<p>Open the folder which holds the certificates you have downloaded.<br>
|
||||
Right-click on the certificate you wish to install, and select
|
||||
<cite>Install PFX</cite> from the context menu.
|
||||
<p><br><img src=../images/cert-wizard1-welcome.jpg >
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Certificate Wizard</cite>
|
||||
welcome window.
|
||||
<p><br><img src=../images/cert-wizard2-select-file.jpg>
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Select File to Import</cite> window.
|
||||
<p><br><img src=../images/cert-wizard3-password.jpg>
|
||||
<p>The personal e-mail certificate files created by PHPki contain an encrypted
|
||||
copy of your private key. When your certficate was created, a password was
|
||||
given to PHPki to encrypt the private key. The same password is used to
|
||||
decrypt your private key and install the certificate. Do not forget or lose
|
||||
this password as it cannot be recovered under any circumstance.
|
||||
Select the <cite>Enable strong private key protection</cite> option if you
|
||||
would like Windows to add an additional layer of password protection to use
|
||||
your certificate. This is not necessary, and will not be covered further here.
|
||||
There is no need to select the <cite>Mark the private key as exportable</cite>
|
||||
option. Enter your certificate password and click the <cite>Next</cite> button
|
||||
in the <cite>Password Protection for Private Keys</cite> window.
|
||||
<p><br><img src=../images/cert-wizard4-select-store.jpg>
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Select a Certificate Store</cite> window.
|
||||
<p><br><img src=../images/cert-wizard5-user-final.jpg>
|
||||
<p>Click the <cite>Finish</cite> button in the <cite>Complete the Certificate..</cite> window.
|
||||
<p><br><img src=../images/import-successful.jpg>
|
||||
<p>Windows confirms the root certificate was successfully imported.<br>
|
||||
|
||||
</h4>
|
||||
<body>
|
||||
<center>
|
||||
<h1>Personal E-mail Certificate Installation for Outlook & Outlook Express</h1>
|
||||
|
||||
<h2>A Step-by-Step Guide</h2>
|
||||
</center><br>
|
||||
|
||||
<p><img src="../images/right-click-install-usercert.jpg"></p>
|
||||
|
||||
<p>Open the folder which holds the certificates you have downloaded.<br>
|
||||
Right-click on the certificate you wish to install, and select <cite>Install PFX</cite> from the context menu.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard1-welcome.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Certificate Wizard</cite> welcome window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard2-select-file.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Select File to Import</cite> window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard3-password.jpg"></p>
|
||||
|
||||
<p>The personal e-mail certificate files created by PHPki contain an encrypted copy of your private key. When your certficate was created, a password was given to PHPki to encrypt the private key. The same password is used to decrypt your private key and install the certificate. Do not forget or lose this password as it cannot be recovered under any circumstance. Select the <cite>Enable strong private key protection</cite> option if you would like Windows to add an additional layer of password protection to use your certificate. This is not necessary, and will not be covered further here. There is no need to select the <cite>Mark the private key as exportable</cite> option. Enter your certificate password and click the <cite>Next</cite> button in the <cite>Password Protection for Private Keys</cite> window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard4-select-store.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Next</cite> button in the <cite>Select a Certificate Store</cite> window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/cert-wizard5-user-final.jpg"></p>
|
||||
|
||||
<p>Click the <cite>Finish</cite> button in the <cite>Complete the Certificate..</cite> window.</p>
|
||||
|
||||
<p><br>
|
||||
<img src="../images/import-successful.jpg"></p>
|
||||
|
||||
<p>Windows confirms the root certificate was successfully imported.<br></p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -2,15 +2,17 @@
|
||||
|
||||
umask(0007);
|
||||
|
||||
if (isset($_SERVER['PHP_AUTH_USER']))
|
||||
if (isset($_SERVER['PHP_AUTH_USER'])) {
|
||||
$PHPki_user = md5($_SERVER['PHP_AUTH_USER']);
|
||||
else
|
||||
} else {
|
||||
$PHPki_user = md5('default');
|
||||
}
|
||||
|
||||
$PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, "utf-8");
|
||||
|
||||
|
||||
function printHeader($withmenu="default") {
|
||||
function printHeader($withmenu = "default")
|
||||
{
|
||||
global $config;
|
||||
$title = ($config['header_title']?$config['header_title']:'PHPki Certificate Authority');
|
||||
|
||||
@@ -64,8 +66,7 @@ function printHeader($withmenu="default") {
|
||||
$logoclass = 'logo-konq';
|
||||
$titleclass = 'title-konq';
|
||||
$menuclass = 'headermenu-konq';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$logoclass = 'logo-ie';
|
||||
$titleclass = 'title-ie';
|
||||
$menuclass = 'headermenu-ie';
|
||||
@@ -95,8 +96,7 @@ function printHeader($withmenu="default") {
|
||||
if (DEMO) {
|
||||
print "<a class=$menuclass href=\"index.php\">Public</a>";
|
||||
print "<a class=$menuclass href=\"ca/\">Manage</a>";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print "<a class=$menuclass href=\"index.php\">Menu</a>";
|
||||
}
|
||||
|
||||
@@ -116,8 +116,7 @@ function printHeader($withmenu="default") {
|
||||
if (DEMO) {
|
||||
print "<a class=$menuclass href=\"../index.php\">Public</a>";
|
||||
print "<a class=$menuclass href=\"../ca/index.php\">Manage</a>";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
print "<a class=$menuclass href=\"index.php\">Menu</a>";
|
||||
}
|
||||
|
||||
@@ -135,7 +134,8 @@ function printHeader($withmenu="default") {
|
||||
}
|
||||
|
||||
|
||||
function printFooter() {
|
||||
function printFooter()
|
||||
{
|
||||
?>
|
||||
<br />
|
||||
<hr style="width:99%; color:#99caff;" />
|
||||
|
@@ -5,17 +5,20 @@ $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF'], ENT_QUOTES, "utf-8");
|
||||
#
|
||||
# Returns TRUE if browser is Internet Explorer.
|
||||
#
|
||||
function isIE() {
|
||||
function isIE()
|
||||
{
|
||||
global $_SERVER;
|
||||
return strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE');
|
||||
}
|
||||
|
||||
function isKonq() {
|
||||
function isKonq()
|
||||
{
|
||||
global $_SERVER;
|
||||
return strstr($_SERVER['HTTP_USER_AGENT'], 'Konqueror');
|
||||
}
|
||||
|
||||
function isMoz() {
|
||||
function isMoz()
|
||||
{
|
||||
global $_SERVER;
|
||||
return strstr($_SERVER['HTTP_USER_AGENT'], 'Gecko');
|
||||
}
|
||||
@@ -24,7 +27,8 @@ function isMoz() {
|
||||
#
|
||||
# Force upload of specified file to browser.
|
||||
#
|
||||
function upload($source, $destination, $content_type="application/octet-stream") {
|
||||
function upload($source, $destination, $content_type = "application/octet-stream")
|
||||
{
|
||||
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
|
||||
header("Expires: -1");
|
||||
# header("Cache-Control: no-store, no-cache, must-revalidate");
|
||||
@@ -34,9 +38,10 @@ function upload($source, $destination, $content_type="application/octet-stream")
|
||||
|
||||
if (is_array($source)) {
|
||||
$fsize = 0;
|
||||
foreach($source as $f) $fsize += filesize($f);
|
||||
foreach ($source as $f) {
|
||||
$fsize += filesize($f);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$fsize = filesize($source);
|
||||
}
|
||||
|
||||
@@ -44,10 +49,13 @@ function upload($source, $destination, $content_type="application/octet-stream")
|
||||
# header("Content-Disposition: attachment; filename=\"" . $destination ."\"");
|
||||
header("Content-Disposition: filename=\"" . $destination ."\"");
|
||||
|
||||
if (is_array($source))
|
||||
foreach($source as $f) $ret = readfile($f);
|
||||
else
|
||||
if (is_array($source)) {
|
||||
foreach ($source as $f) {
|
||||
$ret = readfile($f);
|
||||
}
|
||||
} else {
|
||||
$ret=readfile($source);
|
||||
}
|
||||
|
||||
# $fd=fopen($source,'r');
|
||||
# fpassthru($fd);
|
||||
@@ -60,12 +68,19 @@ function upload($source, $destination, $content_type="application/octet-stream")
|
||||
# by field name. POST fields have precedence over GET fields.
|
||||
# Quoting/Slashes are stripped if magic quotes gpc is on.
|
||||
#
|
||||
function gpvar($v) {
|
||||
function gpvar($v)
|
||||
{
|
||||
global $_GET, $_POST;
|
||||
$x = "";
|
||||
if (isset($_GET[$v])) $x = $_GET[$v];
|
||||
if (isset($_POST[$v])) $x = $_POST[$v];
|
||||
if (get_magic_quotes_gpc()) $x = stripslashes($x);
|
||||
if (isset($_GET[$v])) {
|
||||
$x = $_GET[$v];
|
||||
}
|
||||
if (isset($_POST[$v])) {
|
||||
$x = $_POST[$v];
|
||||
}
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$x = stripslashes($x);
|
||||
}
|
||||
return $x;
|
||||
}
|
||||
|
||||
@@ -73,22 +88,31 @@ function gpvar($v) {
|
||||
#
|
||||
# Sort a two multidimensional array by one of it's columns
|
||||
#
|
||||
function csort($array, $column, $ascdec=SORT_ASC){
|
||||
function csort($array, $column, $ascdec = SORT_ASC)
|
||||
{
|
||||
|
||||
if (sizeof($array) == 0) return $array;
|
||||
if (sizeof($array) == 0) {
|
||||
return $array;
|
||||
}
|
||||
|
||||
// Sort by digital date rather than text date
|
||||
if ($column == 'issued') $column = "issuedSort";
|
||||
if ($column == 'expires') $column = 'expiresSort';
|
||||
if ($column == 'issued') {
|
||||
$column = "issuedSort";
|
||||
}
|
||||
if ($column == 'expires') {
|
||||
$column = 'expiresSort';
|
||||
}
|
||||
|
||||
if ($column == 'status') {
|
||||
foreach($array as $x) {
|
||||
foreach ($array as $x) {
|
||||
$sortarr[]=$x[$column];
|
||||
$sortdate[] = $x['expiresSort'];
|
||||
}
|
||||
array_multisort($sortarr, $ascdec, $sortdate, SORT_ASC, $array);
|
||||
} else {
|
||||
foreach($array as $x) $sortarr[]=$x[$column];
|
||||
foreach ($array as $x) {
|
||||
$sortarr[]=$x[$column];
|
||||
}
|
||||
array_multisort($sortarr, $ascdec, $array);
|
||||
}
|
||||
return $array;
|
||||
@@ -99,11 +123,13 @@ function csort($array, $column, $ascdec=SORT_ASC){
|
||||
# Returns a value suitable for display in the browser.
|
||||
# Strips slashes if second argument is true.
|
||||
#
|
||||
function htvar($v, $strip=false) {
|
||||
if ($strip)
|
||||
function htvar($v, $strip = false)
|
||||
{
|
||||
if ($strip) {
|
||||
return htmlentities(stripslashes($v), 0, "UTF-8");
|
||||
else
|
||||
} else {
|
||||
return htmlentities($v, 0, "UTF-8");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -113,11 +139,13 @@ function htvar($v, $strip=false) {
|
||||
# provided strings with single-quotes and quotes any
|
||||
# other dangerous characters.
|
||||
#
|
||||
function escshellarg($v, $strip=false) {
|
||||
if ($strip)
|
||||
function escshellarg($v, $strip = false)
|
||||
{
|
||||
if ($strip) {
|
||||
return escapeshellarg(stripslashes($v));
|
||||
else
|
||||
} else {
|
||||
return escapeshellarg($v);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,23 +153,25 @@ function escshellarg($v, $strip=false) {
|
||||
# Similar to escshellarg(), but doesn't surround provided
|
||||
# string with single-quotes.
|
||||
#
|
||||
function escshellcmd($v, $strip=false) {
|
||||
if ($strip)
|
||||
function escshellcmd($v, $strip = false)
|
||||
{
|
||||
if ($strip) {
|
||||
return escapeshellcmd(stripslashes($v));
|
||||
else
|
||||
} else {
|
||||
return escapeshellarg($v);
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Recursively strips slashes from a string or array.
|
||||
#
|
||||
function stripslashes_array(&$a) {
|
||||
function stripslashes_array(&$a)
|
||||
{
|
||||
if (is_array($a)) {
|
||||
foreach($a as $k => $v) {
|
||||
foreach ($a as $k => $v) {
|
||||
my_stripslashes($a[$k]);
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$a = stripslashes($a);
|
||||
}
|
||||
}
|
||||
@@ -150,16 +180,17 @@ function stripslashes_array(&$a) {
|
||||
#
|
||||
# Don't use this.
|
||||
#
|
||||
function undo_magic_quotes(&$a) {
|
||||
if(get_magic_quotes_gpc()) {
|
||||
function undo_magic_quotes(&$a)
|
||||
{
|
||||
if (get_magic_quotes_gpc()) {
|
||||
global $HTTP_POST_VARS, $HTTP_GET_VARS;
|
||||
|
||||
foreach($HTTP_POST_VARS as $k => $v) {
|
||||
foreach ($HTTP_POST_VARS as $k => $v) {
|
||||
stripslashes_array($HTTP_POST_VARS[$k]);
|
||||
global $$k;
|
||||
stripslashes_array($$k);
|
||||
}
|
||||
foreach($HTTP_GET_VARS as $k => $v) {
|
||||
foreach ($HTTP_GET_VARS as $k => $v) {
|
||||
stripslashes_array($HTTP_GET_VARS[$k]);
|
||||
global $$k;
|
||||
stripslashes_array($$k);
|
||||
@@ -170,48 +201,55 @@ function undo_magic_quotes(&$a) {
|
||||
#
|
||||
# Returns TRUE if argument contains only alphabetic characters.
|
||||
#
|
||||
function is_alpha($v) {
|
||||
function is_alpha($v)
|
||||
{
|
||||
#return (eregi('[^A-Z]',$v) ? false : true) ;
|
||||
#return (preg_match('/[^A-Z]'.'/i',$v,PCRE_CASELESS) ? false : true) ; # Replaced eregi() with preg_match()
|
||||
return (preg_match('/[^A-Z]/i',$v) ? false : true) ;
|
||||
return (preg_match('/[^A-Z]/i', $v) ? false : true) ;
|
||||
}
|
||||
|
||||
#
|
||||
# Returns TRUE if argument contains only numeric characters.
|
||||
#
|
||||
function is_num($v) {
|
||||
function is_num($v)
|
||||
{
|
||||
#return (eregi('[^0-9]',$v) ? false : true) ;
|
||||
return (preg_match('/[^0-9]/',$v) ? false : true) ; # Replaced eregi() with preg_match()
|
||||
return (preg_match('/[^0-9]/', $v) ? false : true) ; # Replaced eregi() with preg_match()
|
||||
}
|
||||
|
||||
#
|
||||
# Returns TRUE if argument contains only alphanumeric characters.
|
||||
#
|
||||
function is_alnum($v) {
|
||||
function is_alnum($v)
|
||||
{
|
||||
#return (eregi('[^A-Z0-9]',$v) ? false : true) ;
|
||||
return (preg_match('/[^A-Z0-9]/i',$v) ? false : true) ; # Replaced eregi() with preg_match()
|
||||
return (preg_match('/[^A-Z0-9]/i', $v) ? false : true) ; # Replaced eregi() with preg_match()
|
||||
}
|
||||
|
||||
#
|
||||
# Returns TRUE if argument is in proper e-mail address format.
|
||||
#
|
||||
function is_email($v) {
|
||||
function is_email($v)
|
||||
{
|
||||
#return (eregi('^[^@ ]+\@[^@ ]+\.[A-Z]{2,4}$',$v) ? true : false);
|
||||
return (preg_match('/^[^@ ]+\@[^@ ]+\.[A-Z]{2,4}$'.'/i',$v) ? true : false); # Replaced eregi() with preg_match()
|
||||
return (preg_match('/^[^@ ]+\@[^@ ]+\.[A-Z]{2,4}$'.'/i', $v) ? true : false); # Replaced eregi() with preg_match()
|
||||
}
|
||||
|
||||
#
|
||||
# Returns True if the given string is a IP address
|
||||
#
|
||||
function is_ip( $ip = null ) {
|
||||
if( !$ip or strlen(trim($ip)) == 0){
|
||||
function is_ip($ip = null)
|
||||
{
|
||||
if (!$ip or strlen(trim($ip)) == 0) {
|
||||
return false;
|
||||
}
|
||||
$ip=trim($ip);
|
||||
if(preg_match("/^[0-9]{1,3}(.[0-9]{1,3}){3}$/",$ip)) {
|
||||
foreach(explode(".", $ip) as $block)
|
||||
if($block<0 || $block>255 )
|
||||
if (preg_match("/^[0-9]{1,3}(.[0-9]{1,3}){3}$/", $ip)) {
|
||||
foreach (explode(".", $ip) as $block) {
|
||||
if ($block<0 || $block>255) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -220,9 +258,10 @@ function is_ip( $ip = null ) {
|
||||
#
|
||||
# Returns True if the given string is a valid FQDN
|
||||
#
|
||||
function is_fqdn($FQDN) {
|
||||
function is_fqdn($FQDN)
|
||||
{
|
||||
// remove leading wildcard characters if exist
|
||||
$FQDN = preg_replace('/^\*\./','', $FQDN, 1);
|
||||
$FQDN = preg_replace('/^\*\./', '', $FQDN, 1);
|
||||
return (!empty($FQDN) && preg_match('/^(?=.{1,254}$)((?=[a-z0-9-]{1,63}\.)(xn--+)?[a-z0-9]+(-[a-z0-9]+)*\.)+(xn--+)?[a-z0-9]{2,63}$/i', $FQDN) > 0);
|
||||
}
|
||||
|
||||
@@ -231,26 +270,31 @@ function is_fqdn($FQDN) {
|
||||
# as a match is found.
|
||||
#
|
||||
|
||||
function eregi_array($regexp, $arr) {
|
||||
function eregi_array($regexp, $arr)
|
||||
{
|
||||
|
||||
foreach ($arr as $elem) {
|
||||
#if (eregi($regexp,$elem))
|
||||
if (! preg_match('/^\/.*\/$/', $regexp)) # if it doesn't begin and end with '/'
|
||||
if (! preg_match('/^\/.*\/$/', $regexp)) { # if it doesn't begin and end with '/'
|
||||
$regexp = '/'.$regexp.'/'; # pad the $regexp with '/' to prepare for preg_match()
|
||||
if (preg_match($regexp.'i',$elem)) # Replaced eregi() with preg_match()
|
||||
}
|
||||
if (preg_match($regexp.'i', $elem)) { # Replaced eregi() with preg_match()
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
#
|
||||
# Reads entire file into a string
|
||||
# Same as file_get_contents in php >= 4.3.0
|
||||
#
|
||||
function my_file_get_contents($f) {
|
||||
function my_file_get_contents($f)
|
||||
{
|
||||
return implode('', file($f));
|
||||
}
|
||||
|
||||
function getOSInformation() {
|
||||
function getOSInformation()
|
||||
{
|
||||
if (false == function_exists("shell_exec")) {
|
||||
return null;
|
||||
}
|
||||
@@ -261,4 +305,3 @@ function getOSInformation() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -5,7 +5,8 @@
|
||||
// File name is placed in ./tmp with a random name. It lingers unless
|
||||
// removed manually.
|
||||
//
|
||||
function CA_create_cnf($country='',$province='',$locality='',$organization='',$unit='',$common_name='',$email='',$keysize=2048,$dns_names='',$ip_addr='',$serial='') {
|
||||
function CA_create_cnf($country = '', $province = '', $locality = '', $organization = '', $unit = '', $common_name = '', $email = '', $keysize = 2048, $dns_names = '', $ip_addr = '', $serial = '')
|
||||
{
|
||||
global $config, $PHPki_user;
|
||||
|
||||
$issuer = $PHPki_user;
|
||||
@@ -14,7 +15,6 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
|
||||
$alt_names = "";
|
||||
|
||||
if (! $dns_names == '') {
|
||||
|
||||
$dns_n=explode("\n", $dns_names);
|
||||
$count_dns = $count_dns + 1;
|
||||
$alt_names .= "DNS.$count_dns = $common_name\n";
|
||||
@@ -45,31 +45,31 @@ function CA_create_cnf($country='',$province='',$locality='',$organization='',$u
|
||||
$server_altnames = "DNS:$common_name,email:copy";
|
||||
}
|
||||
|
||||
$configHOME = $config['home_dir'];
|
||||
$configRANDFILE = $config['random'];
|
||||
$configCa_dir = $config['ca_dir'];
|
||||
$configCert_dir = $config['cert_dir'];
|
||||
$configCrl_dir = $config['crl_dir'];
|
||||
$configDatabase = $config['index'];
|
||||
$configNew_certs_dir = $config['new_certs_dir'];
|
||||
$configPrivate_dir = $config['private_dir'];
|
||||
$configSerial = $config['serial'];
|
||||
$configCacert_pem = $config['cacert_pem'];
|
||||
$configCacrl_pem = $config['cacrl_pem'];
|
||||
$configCakey = $config['cakey'];
|
||||
$configDefault_md = $config['default_md'];
|
||||
$configBase_url = $config['base_url'];
|
||||
$configCrl_dist = $config['crl_distrib'];
|
||||
$configComment_root = $config['comment_root'];
|
||||
$configPolicy_url = $config['policy_url'];
|
||||
$configRevoke_url = $config['revoke_url'];
|
||||
$configComment_email = $config['comment_email'];
|
||||
$configComment_sign = $config['comment_sign'];
|
||||
$configComment_srv = $config['comment_srv'];
|
||||
$configHOME = $config['home_dir'];
|
||||
$configRANDFILE = $config['random'];
|
||||
$configCa_dir = $config['ca_dir'];
|
||||
$configCert_dir = $config['cert_dir'];
|
||||
$configCrl_dir = $config['crl_dir'];
|
||||
$configDatabase = $config['index'];
|
||||
$configNew_certs_dir = $config['new_certs_dir'];
|
||||
$configPrivate_dir = $config['private_dir'];
|
||||
$configSerial = $config['serial'];
|
||||
$configCacert_pem = $config['cacert_pem'];
|
||||
$configCacrl_pem = $config['cacrl_pem'];
|
||||
$configCakey = $config['cakey'];
|
||||
$configDefault_md = $config['default_md'];
|
||||
$configBase_url = $config['base_url'];
|
||||
$configCrl_dist = $config['crl_distrib'];
|
||||
$configComment_root = $config['comment_root'];
|
||||
$configPolicy_url = $config['policy_url'];
|
||||
$configRevoke_url = $config['revoke_url'];
|
||||
$configComment_email = $config['comment_email'];
|
||||
$configComment_sign = $config['comment_sign'];
|
||||
$configComment_srv = $config['comment_srv'];
|
||||
|
||||
|
||||
|
||||
$cnf_contents = "
|
||||
$cnf_contents = "
|
||||
HOME = $configHOME
|
||||
RANDFILE = $configRANDFILE
|
||||
dir = $configCa_dir
|
||||
@@ -257,8 +257,8 @@ $alt_names
|
||||
|
||||
|
||||
# Write out the config file.
|
||||
$cnf_file = tempnam('../../tmp','cnf-'); // Why is this not in the phpki dir ? why ../../ ?
|
||||
$handle = fopen($cnf_file,"w");
|
||||
$cnf_file = tempnam('../../tmp', 'cnf-'); // Why is this not in the phpki dir ? why ../../ ?
|
||||
$handle = fopen($cnf_file, "w");
|
||||
fwrite($handle, $cnf_contents);
|
||||
fclose($handle);
|
||||
|
||||
@@ -271,34 +271,44 @@ $alt_names
|
||||
// Fields: serial, country, province, locality, organization,
|
||||
// issuer, unit, common_name, email
|
||||
//
|
||||
function CAdb_to_array($search = '.*') {
|
||||
function CAdb_to_array($search = '.*')
|
||||
{
|
||||
global $config;
|
||||
|
||||
# Prepend a default status to search string if missing.
|
||||
#if (! ereg('^\^\[.*\]', $search)) $search = '^[VRE].*'.$search;
|
||||
if (! preg_match("/^\^\[.*\]/", $search)) $search = '^[VRE].*'.$search;
|
||||
if (! preg_match("/^\^\[.*\]/", $search)) {
|
||||
$search = '^[VRE].*'.$search;
|
||||
}
|
||||
# Include valid certs?
|
||||
#if (ereg('^\^\[.*V.*\]',$search)) $inclval = true;
|
||||
if (preg_match('/^\^\[.*V.*\]/',$search)) $inclval = true;
|
||||
if (preg_match('/^\^\[.*V.*\]/', $search)) {
|
||||
$inclval = true;
|
||||
}
|
||||
# Include revoked certs?
|
||||
#if (ereg('^\^\[.*R.*\]',$search)) $inclrev = true;
|
||||
if (preg_match('/^\^\[.*R.*\]/',$search)) $inclrev = true;
|
||||
if (preg_match('/^\^\[.*R.*\]/', $search)) {
|
||||
$inclrev = true;
|
||||
}
|
||||
# Include expired certs?
|
||||
#if (ereg('^\^\[.*E.*\]',$search)) $inclexp = true;
|
||||
if (preg_match('/^\^\[.*E.*\]/',$search)) $inclexp = true;
|
||||
if (preg_match('/^\^\[.*E.*\]/', $search)) {
|
||||
$inclexp = true;
|
||||
}
|
||||
|
||||
# There isn't really a status of 'E' in the openssl index.
|
||||
# Change (E)xpired to (V)alid within the search string.
|
||||
#$search = ereg_replace('^(\^\[.*)E(.*\])','\\1V\\2',$search);
|
||||
$search = preg_replace('/^(\^\[.*)E(.*\])/','${1}V${2}',$search);
|
||||
$search = preg_replace('/^(\^\[.*)E(.*\])/', '${1}V${2}', $search);
|
||||
|
||||
$db = array();
|
||||
exec('egrep -i '.escshellarg($search).' '.$config['index'], $x);
|
||||
foreach($x as $y) {
|
||||
foreach ($x as $y) {
|
||||
$i = CAdb_explode_entry($y);
|
||||
if (($i['status'] == "Valid" && $inclval) || ($i['status'] == "Revoked" && $inclrev) || ($i['status'] == "Expired" && $inclexp))
|
||||
if (($i['status'] == "Valid" && $inclval) || ($i['status'] == "Revoked" && $inclrev) || ($i['status'] == "Expired" && $inclexp)) {
|
||||
$db[$i['serial']] = $i;
|
||||
}
|
||||
}
|
||||
|
||||
return($db);
|
||||
}
|
||||
@@ -308,13 +318,14 @@ function CAdb_to_array($search = '.*') {
|
||||
// Returns an array containing the index record for
|
||||
// certificate $serial.
|
||||
//
|
||||
function CAdb_get_entry($serial) {
|
||||
function CAdb_get_entry($serial)
|
||||
{
|
||||
global $config;
|
||||
$regexp = "^[VR]\t.*\t.*\t$serial\t.*\t.*$";
|
||||
$x = exec('egrep '.escshellarg($regexp).' '.$config['index']);
|
||||
if ($x)
|
||||
if ($x) {
|
||||
return CAdb_explode_entry($x);
|
||||
else {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -324,7 +335,8 @@ function CAdb_get_entry($serial) {
|
||||
// Returns the serial number of a VALID certificate matching
|
||||
// $email and/or $name. Returns FALSE if no match is found.
|
||||
//
|
||||
function CAdb_in($email="", $name="") {
|
||||
function CAdb_in($email = "", $name = "")
|
||||
{
|
||||
global $config;
|
||||
$email = escshellcmd($email);
|
||||
$name = escshellcmd($name);
|
||||
@@ -334,31 +346,34 @@ function CAdb_in($email="", $name="") {
|
||||
if ($x) {
|
||||
list($j,$j,$j,$serial,$j,$j) = explode("\t", $x);
|
||||
return "$serial";
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Alias for CAdb_in()
|
||||
//
|
||||
function CAdb_serial($email, $name='') {
|
||||
return CAdb_in($email, $name='');
|
||||
function CAdb_serial($email, $name = '')
|
||||
{
|
||||
return CAdb_in($email, $name = '');
|
||||
}
|
||||
|
||||
//
|
||||
// Alias for CAdb_in()
|
||||
//
|
||||
function CAdb_exists($email, $name='') {
|
||||
return CAdb_in($email, $name='');
|
||||
function CAdb_exists($email, $name = '')
|
||||
{
|
||||
return CAdb_in($email, $name = '');
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Returns the certificate 'issuer'
|
||||
//
|
||||
function CAdb_issuer($serial) {
|
||||
function CAdb_issuer($serial)
|
||||
{
|
||||
global $config;
|
||||
$rec = CAdb_get_entry($serial);
|
||||
return $rec['issuer'];
|
||||
@@ -370,7 +385,8 @@ function CAdb_issuer($serial) {
|
||||
// Fields: serial, country, province locality, organization,
|
||||
// issuer, unit, common_name, email
|
||||
//
|
||||
function CAdb_explode_entry($dbentry) {
|
||||
function CAdb_explode_entry($dbentry)
|
||||
{
|
||||
$a = explode("\t", $dbentry);
|
||||
$b = preg_split('/\/([A-Z]|[a-z])+=/', $a[5]);
|
||||
|
||||
@@ -387,11 +403,11 @@ function CAdb_explode_entry($dbentry) {
|
||||
// A date will be returned in this format
|
||||
// Feb 27 16:00:09 2020 GMT
|
||||
// Add a 'digital' sort key for digital date sorting later
|
||||
sscanf(CA_cert_startdate($a[3]),"%s%s%s%s", $mm,$dd,$tt,$yy);
|
||||
sscanf(CA_cert_startdate($a[3]), "%s%s%s%s", $mm, $dd, $tt, $yy);
|
||||
$db['issued'] = strftime("%Y-%b-%d", strtotime("$yy-$mm-$dd"));
|
||||
$db['issuedSort'] = strftime("%Y-%m-%d", strtotime("$yy-$mm-$dd"));
|
||||
|
||||
sscanf(CA_cert_enddate($a[3]), "%s%s%s%s",$mm,$dd,$tt,$yy);
|
||||
sscanf(CA_cert_enddate($a[3]), "%s%s%s%s", $mm, $dd, $tt, $yy);
|
||||
$db['expires'] = strftime("%Y-%b-%d", strtotime("$yy-$mm-$dd"));
|
||||
$db['expiresSort'] = strftime("%Y-%m-%d", strtotime("$yy-$mm-$dd"));
|
||||
|
||||
@@ -401,7 +417,7 @@ function CAdb_explode_entry($dbentry) {
|
||||
|
||||
|
||||
// Compatibility with migrated certs from openvpn-bridge
|
||||
if(count($b) == 7){
|
||||
if (count($b) == 7) {
|
||||
$db['serial'] = $a[3];
|
||||
$db['country'] = $b[1];
|
||||
$db['province'] = $b[2];
|
||||
@@ -411,9 +427,8 @@ function CAdb_explode_entry($dbentry) {
|
||||
$db['unit'] = $b[4];
|
||||
$db['common_name'] = $b[5];
|
||||
$db['email'] = $b[6];
|
||||
}
|
||||
// Compatibility with renewed certs from openvpn-bridge
|
||||
elseif(count($b) == 8){
|
||||
} // Compatibility with renewed certs from openvpn-bridge
|
||||
elseif (count($b) == 8) {
|
||||
$db['serial'] = $a[3];
|
||||
$db['country'] = $b[1];
|
||||
$db['province'] = $b[2];
|
||||
@@ -423,9 +438,8 @@ function CAdb_explode_entry($dbentry) {
|
||||
$db['unit'] = $b[5];
|
||||
$db['common_name'] = $b[6];
|
||||
$db['email'] = $b[7];
|
||||
}
|
||||
// Else, it's a certificate created with phpki
|
||||
else{
|
||||
} // Else, it's a certificate created with phpki
|
||||
else {
|
||||
$db['serial'] = $a[3];
|
||||
$db['country'] = $b[1];
|
||||
$db['province'] = $b[2];
|
||||
@@ -444,7 +458,8 @@ function CAdb_explode_entry($dbentry) {
|
||||
// Returns the date & time a specified certificate is revoked,
|
||||
// Returns FALSE if the certificate is not revoked.
|
||||
//
|
||||
function CAdb_is_revoked($serial) {
|
||||
function CAdb_is_revoked($serial)
|
||||
{
|
||||
global $config;
|
||||
$regexp = "^R\t.*\t.*\t$serial\t.*\t.*$";
|
||||
$x = exec('egrep '.escshellarg($regexp).' '.$config['index']);
|
||||
@@ -453,31 +468,34 @@ function CAdb_is_revoked($serial) {
|
||||
list($j,$j,$revoke_date,$j,$j,$j) = explode("\t", $x);
|
||||
// Revoke date = 'R' + start date and is in this format
|
||||
// 200227162209Z
|
||||
sscanf($revoke_date, "%2s%2s%2s",$yy,$mm,$dd);
|
||||
sscanf($revoke_date, "%2s%2s%2s", $yy, $mm, $dd);
|
||||
return strftime("%b %d, %Y", strtotime("$yy-$mm-$dd"));
|
||||
}
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Returns TRUE if a certificate is valid, otherwise FALSE.
|
||||
//
|
||||
function CAdb_is_valid($serial) {
|
||||
function CAdb_is_valid($serial)
|
||||
{
|
||||
global $config;
|
||||
$regexp = "^V\t.*\t.*\t$serial\t.*\t.*$";
|
||||
|
||||
if (exec('egrep '.escshellarg($regexp).' '.$config['index']))
|
||||
if (exec('egrep '.escshellarg($regexp).' '.$config['index'])) {
|
||||
return true;
|
||||
else
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the long-form certificate description as output by
|
||||
// openssl x509 -in certificatefile -text -purpose
|
||||
//
|
||||
function CA_cert_text($serial) {
|
||||
function CA_cert_text($serial)
|
||||
{
|
||||
global $config;
|
||||
$certfile = $config['new_certs_dir'] . '/' . $serial . '.pem';
|
||||
return(shell_exec(X509.' -in '.escshellarg($certfile).' -text -purpose 2>&1'));
|
||||
@@ -487,26 +505,30 @@ function CA_cert_text($serial) {
|
||||
// Returns the long-form text of the Certificate Revocation List
|
||||
// openssl crl -in crlfile -text
|
||||
//
|
||||
function CA_crl_text() {
|
||||
function CA_crl_text()
|
||||
{
|
||||
global $config;
|
||||
$crlfile = $config['cacrl_pem'];
|
||||
return(shell_exec(CRL.' -in '.escshellarg($crlfile).' -text 2>&1'));
|
||||
}
|
||||
|
||||
// Returns the static takey.pem file
|
||||
function ta_key_text() {
|
||||
function ta_key_text()
|
||||
{
|
||||
global $config;
|
||||
return(shell_exec('cat '.escshellarg($config['private_dir']).'/takey.pem 2>&1'));
|
||||
}
|
||||
|
||||
// Returns the dhparam file
|
||||
function dhparam_text() {
|
||||
function dhparam_text()
|
||||
{
|
||||
global $config;
|
||||
return(shell_exec('cat '.escshellarg($config['private_dir']).'/dhparam2048.pem 2>&1'));
|
||||
}
|
||||
|
||||
// Returns the root CA certificate file (PEM Encoded)
|
||||
function root_pem_text() {
|
||||
function root_pem_text()
|
||||
{
|
||||
global $config;
|
||||
return(shell_exec('cat '.escshellarg($config['cacert_pem']).' 2>&1'));
|
||||
}
|
||||
@@ -514,7 +536,8 @@ function root_pem_text() {
|
||||
//
|
||||
// Returns the subject of a certificate.
|
||||
//
|
||||
function CA_cert_subject($serial) {
|
||||
function CA_cert_subject($serial)
|
||||
{
|
||||
global $config;
|
||||
$certfile = $config['new_certs_dir'] . '/' . $serial . '.pem';
|
||||
$x = exec(X509.' -in '.escshellarg($certfile).' -noout -subject 2>&1');
|
||||
@@ -524,17 +547,18 @@ function CA_cert_subject($serial) {
|
||||
//
|
||||
// Returns the common name of a certificate.
|
||||
//
|
||||
function CA_cert_cname($serial) {
|
||||
function CA_cert_cname($serial)
|
||||
{
|
||||
global $config;
|
||||
#return(ereg_replace('^.*/CN=(.*)/.*','\\1',CA_cert_subject($serial)));
|
||||
return(preg_replace('/^.*\/CN=(.*)\/.*/','${1}',CA_cert_subject($serial)));
|
||||
|
||||
return(preg_replace('/^.*\/CN=(.*)\/.*/', '${1}', CA_cert_subject($serial)));
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the email address of a certificate.
|
||||
//
|
||||
function CA_cert_email($serial) {
|
||||
function CA_cert_email($serial)
|
||||
{
|
||||
global $config;
|
||||
$certfile = $config['new_certs_dir'] . '/' . $serial . '.pem';
|
||||
$x = exec(X509.' -in '.escshellarg($certfile).' -noout -email 2>&1');
|
||||
@@ -544,30 +568,33 @@ function CA_cert_email($serial) {
|
||||
//
|
||||
// Returns the effective date of a certificate.
|
||||
//
|
||||
function CA_cert_startdate($serial) {
|
||||
function CA_cert_startdate($serial)
|
||||
{
|
||||
global $config;
|
||||
$certfile = $config['new_certs_dir'] . '/' . $serial . '.pem';
|
||||
$x = exec(X509.' -in '.escshellarg($certfile).' -noout -startdate 2>&1');
|
||||
return(str_replace('notBefore=','',$x));
|
||||
return(str_replace('notBefore=', '', $x));
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the expiration date of a certificate.
|
||||
//
|
||||
function CA_cert_enddate($serial) {
|
||||
function CA_cert_enddate($serial)
|
||||
{
|
||||
global $config;
|
||||
$certfile = $config['new_certs_dir'] . '/' . $serial . '.pem';
|
||||
$x = exec(X509.' -in '.escshellarg($certfile).' -noout -enddate 2>&1');
|
||||
return(str_replace('notAfter=','',$x));
|
||||
return(str_replace('notAfter=', '', $x));
|
||||
}
|
||||
|
||||
//
|
||||
// Revokes a specified certificate.
|
||||
//
|
||||
function CA_revoke_cert($serial) {
|
||||
function CA_revoke_cert($serial)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$fd = fopen($config['index'],'a');
|
||||
$fd = fopen($config['index'], 'a');
|
||||
flock($fd, LOCK_EX);
|
||||
|
||||
$certfile = $config['new_certs_dir'] . "/$serial.pem";
|
||||
@@ -583,7 +610,7 @@ function CA_revoke_cert($serial) {
|
||||
|
||||
fclose($fd);
|
||||
|
||||
return array(($ret == true || $ret == 0 ? true : false), implode('<br>',$cmd_output));
|
||||
return array(($ret == true || $ret == 0 ? true : false), implode('<br>', $cmd_output));
|
||||
}
|
||||
|
||||
//
|
||||
@@ -593,15 +620,16 @@ function CA_revoke_cert($serial) {
|
||||
//
|
||||
// Returns an array containing the output of failed openssl commands.
|
||||
//
|
||||
function CA_create_cert($cert_type='email',$country,$province,$locality,$organization,$unit,$common_name,$email,$expiry,$passwd,$keysize=2048,$dns_names,$ip_addr) {
|
||||
function CA_create_cert($cert_type = 'email', $country, $province, $locality, $organization, $unit, $common_name, $email, $expiry, $passwd, $keysize = 2048, $dns_names, $ip_addr)
|
||||
{
|
||||
global $config;
|
||||
|
||||
# Wait here if another user has the database locked.
|
||||
$fd = fopen($config['index'],"a");
|
||||
$fd = fopen($config['index'], "a");
|
||||
flock($fd, LOCK_EX);
|
||||
|
||||
# Get the next available serial number
|
||||
$serial = trim(implode('',file($config['serial'])));
|
||||
$serial = trim(implode('', file($config['serial'])));
|
||||
|
||||
$userkey = $config['private_dir'] . "/$serial-key.pem";
|
||||
$userreq = $config['req_dir'] ."/$serial-req.pem";
|
||||
@@ -610,7 +638,7 @@ function CA_create_cert($cert_type='email',$country,$province,$locality,$organiz
|
||||
|
||||
$expiry_days = round($expiry * 365.25, 0);
|
||||
|
||||
$cnf_file = CA_create_cnf($country,$province,$locality,$organization,$unit,$common_name,$email,$keysize,$dns_names,$ip_addr,$serial);
|
||||
$cnf_file = CA_create_cnf($country, $province, $locality, $organization, $unit, $common_name, $email, $keysize, $dns_names, $ip_addr, $serial);
|
||||
|
||||
# Escape certain dangerous characters in user input
|
||||
$email = escshellcmd($email);
|
||||
@@ -624,8 +652,7 @@ function CA_create_cert($cert_type='email',$country,$province,$locality,$organiz
|
||||
|
||||
if (($_passwd) && ($_passwd != "''")) {
|
||||
exec(REQ." -new -newkey rsa:$keysize -keyout '$userkey' -out '$userreq' -config '$cnf_file' -days '$expiry_days' -passout pass:$_passwd 2>&1", $cmd_output, $ret);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
exec(REQ." -new -newkey rsa:$keysize -keyout '$userkey' -out '$userreq' -config '$cnf_file' -days '$expiry_days' -nodes 2>&1", $cmd_output, $ret);
|
||||
}
|
||||
|
||||
@@ -655,8 +682,7 @@ function CA_create_cert($cert_type='email',$country,$province,$locality,$organiz
|
||||
if (($_passwd) && ($_passwd != "''")) {
|
||||
$cmd_output[] = "infile: $usercert keyfile: $userkey outfile: $userpfx pass: $_passwd";
|
||||
exec(PKCS12." -export -in '$usercert' -inkey '$userkey' -certfile '$configCacert_pem' -caname '$configOrganization' -out '$userpfx' -name $friendly_name -rand '$configRandom' -passin pass:$_passwd -passout pass:$_passwd 2>&1", $cmd_output, $ret);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$cmd_output[] = "infile: $usercert keyfile: $userkey outfile: $userpfx";
|
||||
// reetp - this needs looking at
|
||||
exec(PKCS12." -export -in '$usercert' -inkey '$userkey' -certfile '$configCacert_pem' -caname '$configOrganization' -out '$userpfx' -name $friendly_name -nodes -passout pass: 2>&1", $cmd_output, $ret);
|
||||
@@ -668,21 +694,21 @@ function CA_create_cert($cert_type='email',$country,$province,$locality,$organiz
|
||||
fclose($fd);
|
||||
|
||||
#Remove temporary openssl config file.
|
||||
if (file_exists($cnf_file)) unlink($cnf_file);
|
||||
if (file_exists($cnf_file)) {
|
||||
unlink($cnf_file);
|
||||
}
|
||||
|
||||
if ($ret == 0) {
|
||||
# Successful!
|
||||
# Return status=true and serial number of issued certificate.
|
||||
return array(true, $serial);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
# Not successful. :-(
|
||||
# Clean up our loose ends.
|
||||
# Return status=false and openssl output/errors for debug.
|
||||
CA_remove_cert($serial);
|
||||
$cmd_output[] = 'Click on the "Help" link above for information on how to report this problem.';
|
||||
return array(false, implode("<br>",$cmd_output));
|
||||
return array(false, implode("<br>", $cmd_output));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -696,20 +722,25 @@ function CA_create_cert($cert_type='email',$country,$province,$locality,$organiz
|
||||
// FIXME: Yes, I know... This functions contains much duplicative code
|
||||
// from CA_create_cert(). Bleh!
|
||||
//
|
||||
function CA_renew_cert($old_serial,$expiry,$passwd) {
|
||||
function CA_renew_cert($old_serial, $expiry, $passwd)
|
||||
{
|
||||
global $config;
|
||||
|
||||
# Do not renew a revoked certificate if a valid one exists for this
|
||||
# URL. Find and renew the valid certificate instead.
|
||||
if (CAdb_is_revoked($old_serial)) {
|
||||
$ret = CAdb_in(CA_cert_email($old_serial),CA_cert_cname($old_serial));
|
||||
if ($ret && $old_serial != $ret) $old_serial = $ret;
|
||||
$ret = CAdb_in(CA_cert_email($old_serial), CA_cert_cname($old_serial));
|
||||
if ($ret && $old_serial != $ret) {
|
||||
$old_serial = $ret;
|
||||
}
|
||||
}
|
||||
|
||||
# Valid certificates must be revoked prior to renewal.
|
||||
if (CAdb_is_valid($old_serial)) {
|
||||
$ret = CA_revoke_cert($old_serial);
|
||||
if (! $ret[0]) return $ret;
|
||||
if (! $ret[0]) {
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
$cert_type = CA_cert_type($old_serial);
|
||||
@@ -727,11 +758,11 @@ function CA_renew_cert($old_serial,$expiry,$passwd) {
|
||||
$email = $rec['email'];
|
||||
|
||||
# Wait here if another user has the database locked.
|
||||
$fd = fopen($config['index'],"a");
|
||||
$fd = fopen($config['index'], "a");
|
||||
flock($fd, LOCK_EX);
|
||||
|
||||
# Get the next available serial number
|
||||
$serial = trim(implode('',file($config['serial'])));
|
||||
$serial = trim(implode('', file($config['serial'])));
|
||||
|
||||
$old_userkey = $config['private_dir'] . "$old_serial-key.pem";
|
||||
$old_userreq = $config['req_dir'] . "/$old_serial-req.pem";
|
||||
@@ -748,18 +779,18 @@ function CA_renew_cert($old_serial,$expiry,$passwd) {
|
||||
$ret = 0;
|
||||
|
||||
# Create a new certificate request by copying the old request.
|
||||
if (! file_exists($old_userreq) || ! copy($old_userreq,$userreq)) {
|
||||
if (! file_exists($old_userreq) || ! copy($old_userreq, $userreq)) {
|
||||
$cmd_output[] = 'Could not create new certificate request file.';
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
# Copy private key to new file.
|
||||
if ($ret == 0 && (! file_exists($old_userkey) || ! copy($old_userkey,$userkey))) {
|
||||
if ($ret == 0 && (! file_exists($old_userkey) || ! copy($old_userkey, $userkey))) {
|
||||
$cmd_output[] = "Could not update private key file.";
|
||||
$ret = 1;
|
||||
}
|
||||
|
||||
$cnf_file = CA_create_cnf($country,$province,$locality,$organization,$unit,$common_name,$email);
|
||||
$cnf_file = CA_create_cnf($country, $province, $locality, $organization, $unit, $common_name, $email);
|
||||
|
||||
# "friendly name" of PKCS12 certificate.
|
||||
$friendly_name = escshellarg($rec['common_name']);
|
||||
@@ -793,13 +824,11 @@ function CA_renew_cert($old_serial,$expiry,$passwd) {
|
||||
if (($_passwd) && ($_passwd != "''")) {
|
||||
$cmd_output[] = "infile: $usercert keyfile: $userkey outfile: $userpfx pass: $_passwd";
|
||||
exec(PKCS12." -export -in '$usercert' -inkey '$userkey' -certfile '$configCacert_pem' -caname '$configOrganization' -out '$userpfx' -name $friendly_name -rand '$configRandom' -passin pass:$_passwd -passout pass:$_passwd 2>&1", $cmd_output, $ret);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$cmd_output[] = "infile: $usercert keyfile: $userkey outfile: $userpfx";
|
||||
// reetp - this needs looking at
|
||||
exec(PKCS12." -export -in '$usercert' -inkey '$userkey' -certfile '$configCacert_pem' -caname '$configOrganization' -out '$userpfx' -name $friendly_name -nodes -passout pass: 2>&1", $cmd_output, $ret);
|
||||
//exec(PKCS12." -export -in '$usercert' -inkey '$userkey' -certfile '$config[cacert_pem]' -caname '$config[organization]' -out '$userpfx' -name $friendly_name -nodes 2>&1", $cmd_output, $ret);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -815,21 +844,23 @@ function CA_renew_cert($old_serial,$expiry,$passwd) {
|
||||
}
|
||||
|
||||
#Remove temporary openssl config file.
|
||||
if (file_exists($cnf_file)) unlink($cnf_file);
|
||||
if (file_exists($cnf_file)) {
|
||||
unlink($cnf_file);
|
||||
}
|
||||
|
||||
if ($ret == 0) {
|
||||
return array(true, $serial);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
# Not successful, so clean up before exiting.
|
||||
CA_remove_cert($serial);
|
||||
|
||||
if (eregi_array('.*private key.*',$cmd_output))
|
||||
if (eregi_array('.*private key.*', $cmd_output)) {
|
||||
$cmd_output[] = '<strong>This was likely caused by entering the wrong certificate password.</strong>';
|
||||
else
|
||||
} else {
|
||||
$cmd_output[] = '<strong>Click on the "Help" link above for information on how to report this problem.</strong>';
|
||||
}
|
||||
|
||||
return array(false, implode('<br>',$cmd_output));
|
||||
return array(false, implode('<br>', $cmd_output));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -837,7 +868,8 @@ function CA_renew_cert($old_serial,$expiry,$passwd) {
|
||||
// Creates a new Certificate Revocation List and copies it the the approriate
|
||||
// locations. Returns error messages from failed commands.
|
||||
//
|
||||
function CA_generate_crl() {
|
||||
function CA_generate_crl()
|
||||
{
|
||||
global $config;
|
||||
|
||||
$configOpenssl_cnf = $config['openssl_cnf'];
|
||||
@@ -855,14 +887,15 @@ function CA_generate_crl() {
|
||||
exec(CRL." -in '$configCacrl_der' -out '$configCacrl_der' -inform PEM -outform DER 2>&1", $cmd_output, $ret);
|
||||
}
|
||||
|
||||
return array(($ret == 0 ? true : false), implode('<br>',$cmd_output));
|
||||
return array(($ret == 0 ? true : false), implode('<br>', $cmd_output));
|
||||
}
|
||||
|
||||
//
|
||||
// Removes a specified certificate from the certificate index,
|
||||
// and all traces of it from the file system.
|
||||
//
|
||||
function CA_remove_cert($serial) {
|
||||
function CA_remove_cert($serial)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$userreq = $config['req_dir'] . "/$serial-req.pem";
|
||||
@@ -874,31 +907,41 @@ function CA_remove_cert($serial) {
|
||||
$configIndex = $config['index'];
|
||||
|
||||
# Wait here if another user has the database locked.
|
||||
$fd = fopen($configIndex,'a');
|
||||
$fd = fopen($configIndex, 'a');
|
||||
flock($fd, LOCK_EX);
|
||||
|
||||
if( file_exists($userreq)) unlink($userreq);
|
||||
if( file_exists($userkey)) unlink($userkey);
|
||||
if( file_exists($usercert)) unlink($usercert);
|
||||
if( file_exists($userder)) unlink($userder);
|
||||
if( file_exists($userpfx)) unlink($userpfx);
|
||||
if (file_exists($userreq)) {
|
||||
unlink($userreq);
|
||||
}
|
||||
if (file_exists($userkey)) {
|
||||
unlink($userkey);
|
||||
}
|
||||
if (file_exists($usercert)) {
|
||||
unlink($usercert);
|
||||
}
|
||||
if (file_exists($userder)) {
|
||||
unlink($userder);
|
||||
}
|
||||
if (file_exists($userpfx)) {
|
||||
unlink($userpfx);
|
||||
}
|
||||
|
||||
$tmpfile = $configIndex .'.tmp';
|
||||
copy($configIndex , $tmpfile);
|
||||
copy($configIndex, $tmpfile);
|
||||
|
||||
$regexp = "^[VR]\t.*\t.*\t".$serial."\t.*\t.*$";
|
||||
exec('egrep -v '.escshellarg($regexp)." $tmpfile > $configIndex 2>/dev/null");
|
||||
|
||||
unlink($tmpfile);
|
||||
fclose($fd);
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Returns the likely intended use for a specified certificate
|
||||
// (email, server, vpn).
|
||||
//
|
||||
function CA_cert_type($serial) {
|
||||
function CA_cert_type($serial)
|
||||
{
|
||||
|
||||
$certtext = CA_cert_text($serial);
|
||||
|
||||
@@ -909,37 +952,30 @@ function CA_cert_type($serial) {
|
||||
#if (ereg('OpenSSL.* (E.?mail|Personal) .*Certificate', $certtext)) {
|
||||
if (preg_match('~OpenSSL.* (E.?mail|Personal) .*Certificate~', $certtext)) {
|
||||
$cert_type = 'email';
|
||||
}
|
||||
#elseif (ereg('OpenSSL.* Server .*Certificate', $certtext)) {
|
||||
} #elseif (ereg('OpenSSL.* Server .*Certificate', $certtext)) {
|
||||
elseif (preg_match('~OpenSSL.* Server .*Certificate~', $certtext)) {
|
||||
$cert_type = 'server';
|
||||
}
|
||||
#elseif (ereg('timeStamping|Time Stamping', $certtext)) {
|
||||
} #elseif (ereg('timeStamping|Time Stamping', $certtext)) {
|
||||
elseif (preg_match('~timeStamping|Time Stamping~', $certtext)) {
|
||||
$cert_type = 'time_stamping';
|
||||
}
|
||||
#elseif (ereg('TLS Web Client Authentication', $certtext) && ereg('TLS Web Server Authentication', $certtext)) {
|
||||
} #elseif (ereg('TLS Web Client Authentication', $certtext) && ereg('TLS Web Server Authentication', $certtext)) {
|
||||
elseif (preg_match('~TLS Web Client Authentication~', $certtext) && preg_match('~TLS Web Server Authentication~', $certtext)) {
|
||||
$cert_type = 'vpn_client_server';
|
||||
}
|
||||
#elseif (ereg('TLS Web Client Authentication', $certtext)) {
|
||||
} #elseif (ereg('TLS Web Client Authentication', $certtext)) {
|
||||
elseif (preg_match('~TLS Web Client Authentication~', $certtext)) {
|
||||
$cert_type = 'vpn_client';
|
||||
}
|
||||
#elseif (ereg('TLS Web Server Authentication', $certtext)) {
|
||||
} #elseif (ereg('TLS Web Server Authentication', $certtext)) {
|
||||
elseif (preg_match('~TLS Web Server Authentication~', $certtext)) {
|
||||
$cert_type = 'vpn_server';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$cert_type = 'vpn_client_server';
|
||||
}
|
||||
|
||||
return $cert_type;
|
||||
}
|
||||
|
||||
function CA_get_root_pem() {
|
||||
function CA_get_root_pem()
|
||||
{
|
||||
global $config;
|
||||
return(file_get_contents($config['cacert_pem']));
|
||||
}
|
||||
|
||||
?>
|
||||
|
56
main.php
56
main.php
@@ -8,19 +8,17 @@ include('./include/openssl_functions.php');
|
||||
|
||||
$stage = gpvar('stage');
|
||||
|
||||
switch($stage) {
|
||||
|
||||
case 'dl_root':
|
||||
switch ($stage) {
|
||||
case 'dl_root':
|
||||
upload($config['cacert_pem'], $config['ca_prefix'] . "cacert.crt", 'application/x-x509-ca-cert');
|
||||
break;
|
||||
|
||||
case 'display_root':
|
||||
case 'display_root':
|
||||
printHeader('public');
|
||||
|
||||
?>
|
||||
<center><h2>Root Certificate (PEM Encoded)</h2></center>
|
||||
<p>
|
||||
<pre><?php echo CA_get_root_pem() ?></pre>
|
||||
<p><pre><?php echo CA_get_root_pem() ?></pre></p>
|
||||
<p>
|
||||
<form action="<?php echo $PHP_SELF?>" method="post">
|
||||
<input type=submit name=submit value="Back to Menu">
|
||||
@@ -28,15 +26,15 @@ case 'display_root':
|
||||
<?php
|
||||
break;
|
||||
|
||||
case 'dl_crl':
|
||||
case 'dl_crl':
|
||||
upload($config['cacrl_der'], $config['ca_prefix'] . "cacrl.crl", 'application/pkix-crl');
|
||||
break;
|
||||
|
||||
case 'dl_crl_pem':
|
||||
case 'dl_crl_pem':
|
||||
upload($config['cacrl_pem'], $config['ca_prefix'] . "cacrl.crl", 'application/octet-stream');
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
printHeader('public');
|
||||
|
||||
?>
|
||||
@@ -44,33 +42,29 @@ default:
|
||||
<br>
|
||||
<center>
|
||||
<table class=menu width=500><th class=menu colspan=2><big>PUBLIC CONTENT MENU<big></th>
|
||||
<tr>
|
||||
<td style="text-align: center; vertical-align: middle; font-weight: bold;" width=35%> <a href=search.php>Search for a Certificate</a></td>
|
||||
<td>Find a digital certificate to download and install in your e-mail or browser application.</td>
|
||||
</tr>
|
||||
|
||||
<tr><td style="text-align: center; vertical-align: middle; font-weight: bold;" width=35%>
|
||||
<a href=search.php>Search for a Certificate</a></td>
|
||||
<td>Find a digital certificate to download and install in your e-mail or browser application.</td></tr>
|
||||
<tr>
|
||||
<td style="text-align: center; vertical-align: middle; font-weight: bold;"> <a href=<?php echo $PHP_SELF?>?stage=dl_root>Download Our Root Certificate</a> </td>
|
||||
<td>You must install our "Root" certificate before you can use any of the certificates issued here. <a href=help.php target=_help>Read the online help</a> to learn more about this.</td>
|
||||
</tr>
|
||||
|
||||
<tr><td style="text-align: center; vertical-align: middle; font-weight: bold;">
|
||||
<a href=<?php echo $PHP_SELF?>?stage=dl_root>Download Our Root Certificate</a></td>
|
||||
<td>You must install our "Root" certificate before you can use any of the
|
||||
certificates issued here. <a href=help.php target=_help>Read the online help</a>
|
||||
to learn more about this.</td></tr>
|
||||
|
||||
<tr><td style="text-align: center; vertical-align: middle; font-weight: bold;">
|
||||
<a href=<?php echo $PHP_SELF?>?stage=display_root>Display Our Root Certificate (PEM Encoded)</a></td>
|
||||
<td>This option provides the "Root" certificate PEM encoded text for advanced users
|
||||
to manually install via copy and paste. <a href=help.php target=_help>Read the online help</a>
|
||||
to learn more about this.</td>
|
||||
|
||||
<tr><td style="text-align: center; vertical-align: middle; font-weight: bold;">
|
||||
|
||||
<a href=<?php echo $PHP_SELF?>?stage=dl_crl>Download Our Certificate Revocation List</a></td>
|
||||
<td>The official list of certificates revoked by this site. Installation and use of
|
||||
this list is optional. Some e-mail programs will reference this list automagically.
|
||||
(<a href="<?php echo $PHP_SELF?>?stage=dl_crl_pem">Some will need it in PEM format.</a>)</td></tr>
|
||||
<tr>
|
||||
<td style="text-align: center; vertical-align: middle; font-weight: bold;"> <a href=<?php echo $PHP_SELF?>?stage=display_root>Display Our Root Certificate (PEM Encoded)</a></td>
|
||||
<td>This option provides the "Root" certificate PEM encoded text for advanced users to manually install via copy and paste. <a href=help.php target=_help>Read the online help</a> to learn more about this.</td>
|
||||
|
||||
<tr>
|
||||
<td style="text-align: center; vertical-align: middle; font-weight: bold;"> <a href=<?php echo $PHP_SELF?>?stage=dl_crl>Download Our Certificate Revocation List</a></td>
|
||||
<td>The official list of certificates revoked by this site. Installation and use of this list is optional. Some e-mail programs will reference this list automagically. (<a href="<?php echo $PHP_SELF?>?stage=dl_crl_pem">Some will need it in PEM format.</a>)</td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<br><br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
|
||||
printFooter();
|
||||
|
@@ -25,8 +25,8 @@ $serial = escapeshellcmd(trim($_SERVER['QUERY_STRING']));
|
||||
$regexp = "^R.*$serial.*$";
|
||||
$configIndex = $config['index'];
|
||||
|
||||
if (exec("egrep '$regexp' '$configIndex'"))
|
||||
if (exec("egrep '$regexp' '$configIndex'")) {
|
||||
print '1';
|
||||
else
|
||||
} else {
|
||||
print '0';
|
||||
?>
|
||||
}
|
||||
|
17
policy.html
17
policy.html
@@ -1,14 +1,15 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>Certificate Authority Issuer's Statement</title>
|
||||
<title>Certificate Authority Issuer's Statement</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1 align=center>Certificate Authority Issuer's Statement</h2>
|
||||
<p>
|
||||
This is a private Limited Liability certificate authority for use by member
|
||||
non-profit agencies.
|
||||
<p>
|
||||
Certificate non-repudiation is achieved via identity verification by password
|
||||
authorized certificate managers from each member agency.
|
||||
<h1 align="center">Certificate Authority Issuer's Statement</h1>
|
||||
|
||||
<p>This is a private Limited Liability certificate authority for use by member non-profit agencies.</p>
|
||||
|
||||
<p>Certificate non-repudiation is achieved via identity verification by password authorized certificate managers from each member agency.</p>
|
||||
</body>
|
||||
</html>
|
||||
|
@@ -10,4 +10,3 @@ print '<pre>';
|
||||
readfile('./README.md');
|
||||
print '</pre>';
|
||||
printFooter();
|
||||
?>
|
||||
|
25
search.php
25
search.php
@@ -15,36 +15,41 @@ $show_revoked = gpvar('show_revoked');
|
||||
$show_expired = gpvar('show_expired');
|
||||
|
||||
# Force stage back to search form if search string is empty.
|
||||
if ($stage == "search" && ! $search) $stage = "";
|
||||
if ($stage == "search" && ! $search) {
|
||||
$stage = "";
|
||||
}
|
||||
|
||||
# Force filter to (V)alid certs if no search status is selected.
|
||||
if ( !($show_valid.$show_revoked.$show_expired) ) $show_valid = 'V';
|
||||
if (!($show_valid.$show_revoked.$show_expired)) {
|
||||
$show_valid = 'V';
|
||||
}
|
||||
|
||||
switch ($stage) {
|
||||
case 'display':
|
||||
case 'display':
|
||||
printHeader('about');
|
||||
|
||||
print '
|
||||
<center><h2>Certificate Details</h2></center>
|
||||
<center><font color=#0000AA><h3>(#'.htvar($serial).')<br>'.htvar(CA_cert_cname($serial).' <'.CA_cert_email($serial).'>').'</h3></font></center>';
|
||||
|
||||
if ($revoke_date = CAdb_is_revoked($serial))
|
||||
if ($revoke_date = CAdb_is_revoked($serial)) {
|
||||
print '<center><font color=red><h2>REVOKED '.htvar($revoke_date).'</h2></font></center>';
|
||||
}
|
||||
|
||||
print '<pre>'.htvar(CA_cert_text($serial)).'</pre>';
|
||||
break;
|
||||
|
||||
case 'download':
|
||||
case 'download':
|
||||
$rec = CAdb_get_entry($serial);
|
||||
upload($config['cert_dir'] . "/$serial.der", $rec['common_name'] . ".cer", 'application/pkix-cert');
|
||||
break;
|
||||
|
||||
case 'download_pem':
|
||||
case 'download_pem':
|
||||
$rec = CAdb_get_entry($serial);
|
||||
upload($config['new_certs_dir'] . "/$serial.pem", $rec['common_name'] . ".pem", 'application/pkix-cert');
|
||||
break;
|
||||
|
||||
case 'search':
|
||||
case 'search':
|
||||
printHeader('public');
|
||||
|
||||
$db = CAdb_to_array("^[${show_valid}${show_revoked}${show_expired}].*$search");
|
||||
@@ -78,12 +83,12 @@ case 'search':
|
||||
);
|
||||
|
||||
print '<tr>';
|
||||
foreach($headings as $field=>$head) {
|
||||
foreach ($headings as $field => $head) {
|
||||
print '<th>'.htvar($head). '</th>';
|
||||
}
|
||||
print '</tr>';
|
||||
|
||||
foreach($db as $rec) {
|
||||
foreach ($db as $rec) {
|
||||
$stcolor = array(Valid=>'green',Revoked=>'red',Expired=>'orange');
|
||||
|
||||
?>
|
||||
@@ -123,7 +128,7 @@ case 'search':
|
||||
printFooter();
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
printHeader('public');
|
||||
|
||||
?>
|
||||
|
Reference in New Issue
Block a user