diff options
Diffstat (limited to 'includes/account.php')
-rw-r--r-- | includes/account.php | 166 |
1 files changed, 150 insertions, 16 deletions
diff --git a/includes/account.php b/includes/account.php index 685b53a..24c61d8 100644 --- a/includes/account.php +++ b/includes/account.php @@ -299,6 +299,15 @@ $_SESSION['_config']['rootcert'] = 1; $emails .= "SPKAC = $spkac"; + if (($weakKey = checkWeakKeySPKAC($emails)) !== "") + { + $id = 4; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $query = "insert into emailcerts set `CN`='$defaultemail', `keytype`='NS', @@ -330,6 +339,16 @@ } else if($_REQUEST['keytype'] == "MS" || $_REQUEST['keytype'] == "VI") { if($csr == "") $csr = "-----BEGIN CERTIFICATE REQUEST-----\n".clean_csr($_REQUEST['CSR'])."\n-----END CERTIFICATE REQUEST-----\n"; + + if (($weakKey = checkWeakKeyCSR($csr)) !== "") + { + $id = 4; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $tmpfname = tempnam("/tmp", "id4CSR"); $fp = fopen($tmpfname, "w"); fputs($fp, $csr); @@ -613,17 +632,23 @@ if($process != "" && $oldid == 10) { $CSR = clean_csr($_REQUEST['CSR']); - $_SESSION['_config']['tmpfname'] = tempnam("/tmp", "id10CSR"); - $fp = fopen($_SESSION['_config']['tmpfname'], "w"); if(strpos($CSR,"---BEGIN")===FALSE) { // In case the CSR is missing the ---BEGIN lines, add them automatically: - fputs($fp,"-----BEGIN CERTIFICATE REQUEST-----\n".$CSR."\n-----END CERTIFICATE REQUEST-----\n"); + $CSR = "-----BEGIN CERTIFICATE REQUEST-----\n".$CSR."\n-----END CERTIFICATE REQUEST-----\n"; } - else + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") { - fputs($fp, $CSR); + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; } + + $_SESSION['_config']['tmpfname'] = tempnam("/tmp", "id10CSR"); + $fp = fopen($_SESSION['_config']['tmpfname'], "w"); + fputs($fp, $CSR); fclose($fp); $CSR = $_SESSION['_config']['tmpfname']; $_SESSION['_config']['subject'] = trim(`/usr/bin/openssl req -text -noout -in "$CSR"|tr -d "\\0"|grep "Subject:"`); @@ -658,6 +683,23 @@ if($process != "" && $oldid == 11) { + if(!file_exists($_SESSION['_config']['tmpfname'])) + { + showheader(_("My CAcert.org Account!")); + printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions."), "<a href='http://wiki.cacert.org/wiki/FAQ/CertificateRenewal'>", "</a>"); + showfooter(); + exit; + } + + if (($weakKey = checkWeakKeyCSR(file_get_contents( + $_SESSION['_config']['tmpfname']))) !== "") + { + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $id = 11; if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { @@ -731,13 +773,6 @@ mysql_query("insert into `domlink` set `certid`='$CSRid', `domid`='$dom'"); $CSRname=generatecertpath("csr","server",$CSRid); - if(!file_exists($_SESSION['_config']['tmpfname'])) - { - showheader(_("My CAcert.org Account!")); - printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions."), "<a href='http://wiki.cacert.org/wiki/FAQ/CertificateRenewal'>", "</a>"); - showfooter(); - exit; - } rename($_SESSION['_config']['tmpfname'], $CSRname); chmod($CSRname,0644); mysql_query("update `domaincerts` set `CSR_name`='$CSRname' where `id`='$CSRid'"); @@ -780,8 +815,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br/>\n", $id); continue; } - mysql_query("update `domaincerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `domaincerts` set `renewed`='1' where `id`='$id'"); $query = "insert into `domaincerts` set `domid`='".$row['domid']."', `CN`='".mysql_real_escape_string($row['CN'])."', @@ -946,8 +990,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br>\n", $id); continue; } - mysql_query("update `emailcerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `emailcerts` set `renewed`='1' where `id`='$id'"); $query = "insert into emailcerts set `memid`='".$row['memid']."', `CN`='".mysql_real_escape_string($row['CN'])."', @@ -1237,6 +1290,8 @@ showheader(_("My CAcert.org Account!")); if($_SESSION['_config']['user']['pword1'] == "" || $_SESSION['_config']['user']['pword1'] != $_SESSION['_config']['user']['pword2']) { + echo '<h3 style="color:red">', _("Failure: Pass Phrase not Changed"), + '</h3>', "\n"; echo _("New Pass Phrases specified don't match or were blank."); } else { $score = checkpw($_SESSION['_config']['user']['pword1'], $_SESSION['profile']['email'], $_SESSION['profile']['fname'], @@ -1253,14 +1308,21 @@ } if(strlen($_SESSION['_config']['user']['pword1']) < 6) { + echo '<h3 style="color:red">', + _("Failure: Pass Phrase not Changed"), '</h3>', "\n"; echo _("The Pass Phrase you submitted was too short."); } else if($score < 3) { + echo '<h3 style="color:red">', + _("Failure: Pass Phrase not Changed"), '</h3>', "\n"; printf(_("The Pass Phrase you submitted failed to contain enough differing characters and/or contained words from your name and/or email address. Only scored %s points out of 6."), $score); } else if($rc <= 0) { + echo '<h3 style="color:red">', + _("Failure: Pass Phrase not Changed"), '</h3>', "\n"; echo _("You failed to correctly enter your current Pass Phrase."); } else { mysql_query("update `users` set `password`=sha1('".$_SESSION['_config']['user']['pword1']."') where `id`='".$_SESSION['profile']['id']."'"); + echo '<h3>', _("Pass Phrase Changed Successfully"), '</h3>', "\n"; echo _("Your Pass Phrase has been updated and your primary email account has been notified of the change."); $body = sprintf(_("Hi %s,"),$_SESSION['profile']['fname'])."\n"; $body .= _("You are receiving this email because you or someone else")."\n"; @@ -1378,6 +1440,15 @@ $_SESSION['_config']['rootcert'] = 1; $emails .= "SPKAC = $spkac"; + if (($weakKey = checkWeakKeySPKAC($emails)) !== "") + { + $id = 17; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $query = "insert into `orgemailcerts` set `CN`='$defaultemail', `keytype`='NS', @@ -1408,6 +1479,16 @@ mysql_query("update `orgemailcerts` set `csr_name`='$CSRname' where `id`='$emailid'"); } else if($_REQUEST['keytype'] == "MS" || $_REQUEST['keytype']=="VI") { $csr = "-----BEGIN CERTIFICATE REQUEST-----\n".clean_csr($_REQUEST['CSR'])."-----END CERTIFICATE REQUEST-----\n"; + + if (($weakKey = checkWeakKeyCSR($csr)) !== "") + { + $id = 17; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $tmpfname = tempnam("/tmp", "id17CSR"); $fp = fopen($tmpfname, "w"); fputs($fp, $csr); @@ -1514,8 +1595,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br>\n", $id); continue; } - mysql_query("update `orgemailcerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `orgemailcerts` set `renewed`='1' where `id`='$id'"); if($row['revoke'] > 0) { printf(_("It would seem '%s' has already been revoked. I'll skip this for now.")."<br>\n", $row['CN']); @@ -1625,6 +1715,16 @@ if($process != "" && $oldid == 20) { $CSR = clean_csr($_REQUEST['CSR']); + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") + { + $id = 20; + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } + $_SESSION['_config']['tmpfname'] = tempnam("/tmp", "id20CSR"); $fp = fopen($_SESSION['_config']['tmpfname'], "w"); fputs($fp, $CSR); @@ -1674,6 +1774,23 @@ if($process != "" && $oldid == 21) { $id = 21; + + if(!file_exists($_SESSION['_config']['tmpfname'])) + { + showheader(_("My CAcert.org Account!")); + printf(_("Your certificate request has failed to be processed correctly, see %sthe WIKI page%s for reasons and solutions."), "<a href='http://wiki.cacert.org/wiki/FAQ/CertificateRenewal'>", "</a>"); + showfooter(); + exit; + } + + if (($weakKey = checkWeakKeyCSR(file_get_contents( + $_SESSION['_config']['tmpfname']))) !== "") + { + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } if($_SESSION['_config']['0.CN'] == "" && $_SESSION['_config']['0.subjectAltName'] == "") { @@ -1799,8 +1916,17 @@ printf(_("Invalid ID '%s' presented, can't do anything with it.")."<br>\n", $id); continue; } - mysql_query("update `orgdomaincerts` set `renewed`='1' where `id`='$id'"); + $row = mysql_fetch_assoc($res); + + if (($weakKey = checkWeakKeyX509(file_get_contents( + $row['crt_name']))) !== "") + { + echo $weakKey, "<br/>\n"; + continue; + } + + mysql_query("update `orgdomaincerts` set `renewed`='1' where `id`='$id'"); if($row['revoke'] > 0) { printf(_("It would seem '%s' has already been revoked. I'll skip this for now.")."<br>\n", $row['CN']); @@ -2497,6 +2623,14 @@ showfooter(); exit; } + + if (($weakKey = checkWeakKeyCSR($CSR)) !== "") + { + showheader(_("My CAcert.org Account!")); + echo $weakKey; + showfooter(); + exit; + } $query = "insert into `domaincerts` set `CN`='".$_SESSION['_config']['0.CN']."', |