diff options
author | Michael Tänzer <neo@nhng.de> | 2013-11-06 02:36:43 +0100 |
---|---|---|
committer | Michael Tänzer <neo@nhng.de> | 2013-11-06 02:36:43 +0100 |
commit | 3b2bd82ed84f3d2350be64f46c45acd7d40e4a60 (patch) | |
tree | 1ac620121350bc16d965e3b1d3fb7869f717ee09 | |
parent | 1711156616d895174df28a6e2827cb0326ea9e84 (diff) | |
download | cacert-devel-3b2bd82ed84f3d2350be64f46c45acd7d40e4a60.tar.gz cacert-devel-3b2bd82ed84f3d2350be64f46c45acd7d40e4a60.tar.xz cacert-devel-3b2bd82ed84f3d2350be64f46c45acd7d40e4a60.zip |
bug 440: Use convenience function to extract the domains from the session variables
Signed-off-by: Michael Tänzer <neo@nhng.de>
-rw-r--r-- | includes/account.php | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/includes/account.php b/includes/account.php index fe7ab73..9d48e73 100644 --- a/includes/account.php +++ b/includes/account.php @@ -20,21 +20,6 @@ loadem("account"); -function appendUnique($str, $suffix) { - if (!strstr($str, "$suffix/") && - substr($str, -strlen($suffix)) != $suffix) { - $str .= $suffix; - } - return $str; -} - -function appendSubjectAltName($subject, $name) { - $subject = appendUnique($subject, "/subjectAltName=DNS:$name"); - $subject = appendUnique($subject, "/subjectAltName=otherName:1.3.6.1.5.5.7.8.5;UTF8:$name"); - - return $subject; -} - /** * Build a subject string as needed by the signer * @@ -63,6 +48,29 @@ function buildSubject(array $domains, $include_xmpp_addr = true) { return $subject; } +/** + * Builds the subject string from the session variables + * $_SESSION['_config']['rows'] and $_SESSION['_config']['altrows'] + * + * @return string + */ +function buildSubjectFromSession() { + $domains = array(); + + if (is_array($_SESSION['_config']['rows'])) { + $domains = array_merge($domains, $_SESSION['_config']['rows']); + } + + if (is_array($_SESSION['_config']['altrows'])) + foreach ($_SESSION['_config']['altrows'] as $row) { + if (substr($row, 0, 4) === "DNS:") { + $domains[] = substr($row, 4); + } + } + + return buildSubject(array_unique($domains)); +} + $id = 0; if(array_key_exists("id",$_REQUEST)) $id=intval($_REQUEST['id']); $oldid = 0; if(array_key_exists("oldid",$_REQUEST)) $oldid=intval($_REQUEST['oldid']); $process = ""; if(array_key_exists("process",$_REQUEST)) $process=$_REQUEST['process']; @@ -759,7 +767,7 @@ function buildSubject(array $domains, $include_xmpp_addr = true) { exit; } - $subject = buildSubject(); + $subject = buildSubjectFromSession(); if($_SESSION['_config']['rootcert'] < 1 || $_SESSION['_config']['rootcert'] > 2) $_SESSION['_config']['rootcert'] = 1; @@ -879,7 +887,7 @@ function buildSubject(array $domains, $include_xmpp_addr = true) { continue; } - $subject = buildSubject(); + $subject = buildSubjectFromSession(); $subject = mysql_real_escape_string($subject); mysql_query("update `domaincerts` set `subject`='$subject',`csr_name`='$newfile' where `id`='$newid'"); @@ -1828,7 +1836,7 @@ function buildSubject(array $domains, $include_xmpp_addr = true) { //if($org['contact']) // $csrsubject .= "/emailAddress=".trim($org['contact']); - $csrsubject .= buildSubject(); + $csrsubject .= buildSubjectFromSession(); $type=""; if($_REQUEST["ocspcert"]!="" && $_SESSION['profile']['admin'] == 1) $type="8"; |