fixing WILDCARD detection (getBestCert) + sharing button not working

This commit is contained in:
Benjamin Sonntag 2015-05-07 16:47:26 +02:00
parent d30f08f91f
commit 06d3e94a99
2 changed files with 7 additions and 3 deletions

View File

@ -107,8 +107,6 @@ if ($cert["status"] == $ssl::STATUS_PENDING) {
<?php
}
?>
<form method="post" action="ssl_finalize.php" name="main" id="main">
<input type="hidden" name="id" id="id" value="<?php echo $cert["id"]; ?>"/>
<p>
<span class="inb ok"><a href="ssl_list.php"><?php __("Back to my SSL Certificates"); ?></a></span>
</p>

View File

@ -545,21 +545,27 @@ class m_ssl {
$uid = intval($uid);
// 1st search for a valid certificate in my account or shared by the admin:
// the ORDER BY make it so that we try VALID then EXPIRED one (sad)
$wildcard = "*" . substr($fqdn, strpos($fqdn, ".") + 1);
$wildcard = "*." . substr($fqdn, strpos($fqdn, ".") + 1);
$db->query("SELECT * FROM certificates WHERE (status=".self::STATUS_OK." OR status=".self::STATUS_EXPIRED.") "
. "AND (uid=" . $uid . " OR shared=1) "
. "AND (fqdn='" . $fqdn . "' OR fqdn='" . $wildcard . "' OR altnames LIKE '%" . $fqdn . "%') "
. "ORDER BY (validstart<=NOW() AND validend>=NOW()) DESC, validstart DESC ");
while ($db->next_record()) {
// name
if ($db->Record["fqdn"] == $fqdn) {
return $db->Record;
}
// or alternative names
$altnames = explode("\n", $db->Record["altnames"]);
foreach ($altnames as $altname) {
if (trim($altname) == $fqdn) {
return $db->Record;
}
}
// or wildcard
if ($db->Record["fqdn"] == $wildcard) {
return $db->Record;
}
}
// not found, we generate a one-time self-signed certificate for this host.
$crt = $this->selfSigned($fqdn);