diff --git a/includes/account.php b/includes/account.php
index bb9c5cf..92b6f06 100644
--- a/includes/account.php
+++ b/includes/account.php
@@ -44,6 +44,13 @@
showfooter();
exit;
}
+ if(!checkEmail($newemail))
+ {
+ showheader(_("My CAcert.org Account!"));
+ echo _("Email Address given was invalid, or a test connection couldn't be made to your server, or the server rejected the email address as invalid");
+ showfooter();
+ exit;
+ }
$rnd = fopen("/dev/urandom", "r");
$hash = md5(fgets($rnd, 64));
fclose($rnd);
@@ -389,6 +396,13 @@
showfooter();
exit;
}
+ if(!checkEmail($authaddy))
+ {
+ showheader(_("My CAcert.org Account!"));
+ echo _("Email Address given was invalid, or a test connection couldn't be made to your server, or the server rejected the email address as invalid");
+ showfooter();
+ exit;
+ }
$rnd = fopen("/dev/urandom", "r");
$hash = md5(fgets($rnd, 64));
@@ -446,16 +460,22 @@
fclose($fp);
$CSR = $_SESSION['_config']['tmpfname'];
$_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$CSR"|grep Subject:`);
+ $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in "$CSR"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
+ foreach($bits as $val)
+ {
+ $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
+ }
$id = 11;
+ $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = "";
extractit();
getcn();
getalt();
- if($_SESSION['_config']['0.CN'] == "")
+ if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "")
{
showheader(_("My CAcert.org Account!"));
- echo _("CommonName field was blank. Can't continue.");
+ echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue.");
showfooter();
exit;
}
@@ -465,31 +485,50 @@
{
$id = 11;
- if($_SESSION['_config']['0.CN'] == "")
+ if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "")
{
showheader(_("My CAcert.org Account!"));
- echo _("CommonName field was blank. Can't continue.");
+ echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue.");
showfooter();
exit;
}
$subject = "";
- foreach($_SESSION['_config']['rows'] as $row)
- $subject .= "/CN=$row";
+ if(is_array($_SESSION['_config']['rows']))
+ foreach($_SESSION['_config']['rows'] as $row)
+ $subject .= "/CN=$row";
+ if(is_array($_SESSION['_config']['altrows']))
+ foreach($_SESSION['_config']['altrows'] as $row)
+ $subject .= "/subjectAltName=$row";
- $query = "insert into `domaincerts` set `CN`='".$_SESSION['_config']['rows']['0']."',
+ if($_SESSION['_config']['rowid']['0'] > 0)
+ {
+ $query = "insert into `domaincerts` set `CN`='".$_SESSION['_config']['rows']['0']."',
`domid`='".$_SESSION['_config']['rowid']['0']."',
`created`=NOW(),`subject`='$subject'";
+ } else {
+ $query = "insert into `domaincerts` set `CN`='".$_SESSION['_config']['altrows']['0']."',
+ `domid`='".$_SESSION['_config']['altid']['0']."',
+ `created`=NOW(),`subject`='$subject'";
+ }
mysql_query($query);
$CSRid = mysql_insert_id();
- foreach($_SESSION['_config']['rowid'] as $dom)
- mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'");
+ if(is_array($_SESSION['_config']['rowid']))
+ foreach($_SESSION['_config']['rowid'] as $dom)
+ mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'");
if(is_array($_SESSION['_config']['altid']))
foreach($_SESSION['_config']['altid'] as $dom)
mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'");
$CSRname = $_SESSION['_config']['filepath']."/csr/server-$CSRid.csr";
+ if(!file_exists($_SESSION['_config']['tmpfname']))
+ {
+ showheader(_("My CAcert.org Account!"));
+ echo _("Your certificate request has failed to be processed correctly, please try submitting it again.");
+ showfooter();
+ exit;
+ }
rename($_SESSION['_config']['tmpfname'], $CSRname);
mysql_query("update `domaincerts` set `CSR_name`='$CSRname' where `id`='$CSRid'");
$do = `../scripts/runserver`;
@@ -527,6 +566,7 @@
printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id);
continue;
}
+ mysql_query("update `domaincerts` set `renewed`='1' where `id`='$id'");
$row = mysql_fetch_assoc($res);
$query = "insert into `domaincerts` set `domid`='".$row['domid']."', `CN`='".$row['CN']."',
`csr_name`='".$row['csr_name']."', `created`='".$row['created']."',
@@ -536,22 +576,31 @@
$newfile = $_SESSION['_config']['filepath']."/csr/server-$newid.csr";
copy($row['csr_name'], $newfile);
$_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$newfile"|grep Subject:`);
-
+ $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in "$newfile"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
+ foreach($bits as $val)
+ {
+ $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
+ }
+ $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = "";
extractit();
getcn();
getalt();
- if($_SESSION['_config']['0.CN'] == "")
+ if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "")
{
showheader(_("My CAcert.org Account!"));
- echo _("CommonName field was blank. Can't continue.");
+ echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue.");
showfooter();
exit;
}
$subject = "";
- foreach($_SESSION['_config']['rows'] as $row)
- $subject .= "/CN=$row";
+ if(is_array($_SESSION['_config']['rows']))
+ foreach($_SESSION['_config']['rows'] as $row)
+ $subject .= "/CN=$row";
+ if(is_array($_SESSION['_config']['altrows']))
+ foreach($_SESSION['_config']['altrows'] as $row)
+ $subject .= "/subjectAltName=$row";
mysql_query("update `domaincerts` set `subject`='$subject',`csr_name`='$newfile' where `id`='$newid'");
@@ -654,6 +703,7 @@
printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id);
continue;
}
+ mysql_query("update `emailcerts` set `renewed`='1' where `id`='$id'");
$row = mysql_fetch_assoc($res);
$query = "insert into `emailcerts` set `memid`='".$row['memid']."', `CN`='".$row['CN']."',
`keytype`='".$row['keytype']."', `csr_name`='".$row['csr_name']."',
@@ -1052,6 +1102,7 @@
printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id);
continue;
}
+ mysql_query("update `orgemailcerts` set `renewed`='1' where `id`='$id'");
$row = mysql_fetch_assoc($res);
if($row[revoke] > 0)
{
@@ -1154,8 +1205,14 @@
fclose($fp);
$CSR = $_SESSION['_config']['tmpfname'];
$_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$CSR"|grep Subject:`);
+ $bits = explode(",", trim(`/usr/bin/openssl req -text -noout -in "$CSR"|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`));
+ foreach($bits as $val)
+ {
+ $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val);
+ }
$id = 21;
+ $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = "";
extractit();
getcn2();
getalt2();
@@ -1165,13 +1222,20 @@
`org`.`orgid`=`orginfo`.`id` and
`org`.`orgid`=`orgdomains`.`orgid` and
`orgdomains`.`domain`='".$_SESSION['_config']['0.CN']."'";
- $_SESSION['_config'][org] = mysql_fetch_assoc(mysql_query($query));
+ $_SESSION['_config']['CNorg'] = mysql_fetch_assoc(mysql_query($query));
+ $query = "select * from `orginfo`,`org`,`orgdomains` where
+ `org`.`memid`='".$_SESSION['profile']['id']."' and
+ `org`.`orgid`=`orginfo`.`id` and
+ `org`.`orgid`=`orgdomains`.`orgid` and
+ `orgdomains`.`domain`='".$_SESSION['_config']['0.subjectAltName']."'";
+ $_SESSION['_config']['SANorg'] = mysql_fetch_assoc(mysql_query($query));
+//echo "
"; print_r($_SESSION['_config']); die; - if($_SESSION['_config']['0.CN'] == "") + if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { $id = 20; showheader(_("My CAcert.org Account!")); - echo _("CommonName field was blank. Can't continue."); + echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } @@ -1181,18 +1245,26 @@ { $id = 21; - if($_SESSION['_config']['0.CN'] == "") + if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { showheader(_("My CAcert.org Account!")); - echo _("CommonName field was blank. Can't continue."); + echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } - $query = "select * from `org`,`orginfo` where - `orginfo`.`id`='".$_SESSION['_config']['rowid']['0']."' and - `orginfo`.`id`=`org`.`orgid` and - `org`.`memid`='".$_SESSION['profile']['id']."'"; + if($_SESSION['_config']['rowid']['0'] > 0) + { + $query = "select * from `org`,`orginfo` where + `orginfo`.`id`='".$_SESSION['_config']['rowid']['0']."' and + `orginfo`.`id`=`org`.`orgid` and + `org`.`memid`='".$_SESSION['profile']['id']."'"; + } else { + $query = "select * from `org`,`orginfo` where + `orginfo`.`id`='".$_SESSION['_config']['altid']['0']."' and + `orginfo`.`id`=`org`.`orgid` and + `org`.`memid`='".$_SESSION['profile']['id']."'"; + } $org = mysql_fetch_assoc(mysql_query($query)); if($org['OU']) @@ -1213,21 +1285,36 @@ $csrsubject .= "/commonName=$row"; if(is_array($_SESSION['_config']['altrows'])) foreach($_SESSION['_config']['altrows'] as $subalt) - $csrsubject .= "/subjectAltName=$subalt"; + { + if($SAN != "") + $SAN .= ","; + $SAN .= "$subalt"; + } - $query = "insert into `orgdomaincerts` set `CN`='".$_SESSION['_config']['0.CN']."', - `orgid`='".$_SESSION['_config']['row']['id']."', - `created`=NOW(), `subject`='$csrsubject'"; - mysql_query($query); + if($SAN != "") + $csrsubject .= "/subjectAltName=".$SAN."/commonName=*.cacert.org"; + + if($_SESSION['_config']['rowid']['0'] > 0) + { + $query = "insert into `orgdomaincerts` set `CN`='".$_SESSION['_config']['rows']['0']."', + `orgid`='".$org['id']."', + `created`=NOW(),`subject`='$csrsubject'"; + } else { + $query = "insert into `orgdomaincerts` set `CN`='".$_SESSION['_config']['altrows']['0']."', + `orgid`='".$org['id']."', + `created`=NOW(),`subject`='$csrsubject'"; + } + mysql_query($query); $CSRid = mysql_insert_id(); $CSRname = $_SESSION['_config']['filepath']."/csr/orgserver-$CSRid.csr"; rename($_SESSION['_config']['tmpfname'], $CSRname); mysql_query("update `orgdomaincerts` set `CSR_name`='$CSRname' where `id`='$CSRid'"); - foreach($_SESSION['_config']['rowid'] as $id) - mysql_query("insert into `orgdomlink` set `orgdomid`='$id', `orgcertid`='$CSRid'"); + if(is_array($_SESSION['_config']['rowid'])) + foreach($_SESSION['_config']['rowid'] as $id) + mysql_query("insert into `orgdomlink` set `orgdomid`='$id', `orgcertid`='$CSRid'"); if(is_array($_SESSION['_config']['altid'])) - foreach($_SESSION['_config']['altid'] as $id) - mysql_query("insert into `orgdomlink` set `orgdomid`='$id', `orgcertid`='$CSRid'"); + foreach($_SESSION['_config']['altid'] as $id) + mysql_query("insert into `orgdomlink` set `orgdomid`='$id', `orgcertid`='$CSRid'"); $do = `../scripts/runserver`; $query = "select * from `orgdomaincerts` where `id`='$CSRid' and `crt_name` != ''"; $res = mysql_query($query); @@ -1263,6 +1350,7 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."
\n", $id); continue; } + mysql_query("update `orgdomaincerts` set `renewed`='1' where `id`='$id'"); $row = mysql_fetch_assoc($res); if($row[revoke] > 0) { @@ -1752,17 +1840,23 @@ { $CSR = trim($CSR); $_SESSION['_config']['CSR'] = $CSR; - $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text|grep Subject:`); + $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|grep Subject:`); + $bits = explode(",", trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`)); + foreach($bits as $val) + { + $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val); + } $id = 46; + $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = ""; extractit(); getcn(); getalt(); - if($_SESSION['_config']['0.CN'] == "") + if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { showheader(_("My CAcert.org Account!")); - echo _("CommonName field was blank. Can't continue."); + echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } @@ -1771,17 +1865,23 @@ if($process != "" && $oldid == 46) { $CSR = $_SESSION['_config']['CSR']; - $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text|grep Subject:`); + $_SESSION['_config']['subject'] = trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|grep Subject:`); + $bits = explode(",", trim(`echo "$CSR"|/usr/bin/openssl req -text -noout|grep -A1 'X509v3 Subject Alternative Name:'|grep DNS:`)); + foreach($bits as $val) + { + $_SESSION['_config']['subject'] .= "/subjectAltName=".trim($val); + } $id = 11; + $_SESSION['_config']['0.CN'] = $_SESSION['_config']['0.subjectAltName'] = ""; extractit(); getcn(); getalt(); - if($_SESSION['_config']['0.CN'] == "") + if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { showheader(_("My CAcert.org Account!")); - echo _("CommonName field was blank. Can't continue."); + echo _("CommonName field was blank. This is usually caused by entering your own name when openssl prompt's you for 'YOUR NAME', or if you try to issue certificates for domains you haven't already verified, as such this process can't continue."); showfooter(); exit; } diff --git a/includes/account_stuff.php b/includes/account_stuff.php index 428eeb0..8228fab 100644 --- a/includes/account_stuff.php +++ b/includes/account_stuff.php @@ -91,7 +91,10 @@ case 503: case 504: case 505: - case 506: $expand = " explode('WoT');"; break; + case 506: + case 509: + case 510: + case 511: $expand = " explode('WoT');"; break; case 1000: case 1001: case 1002: @@ -192,7 +195,7 @@ function hideall() { } ?> if($_SESSION['profile']['points'] >= 50) { ?>